I have created this simple address form from devexpress components in MVC view. It consists of two groupboxes - the first is with border for 4 rows. The second is inside first groupbox at last line which consists of 3 elements. The first element is 30px wide, the second 60px and the third should just fill the rest of space so he doesn't have fixed width. The whole box is 250px wide. My problem are spaces between textboxes in second groupbox which I can't get rid of. I want the second textbox to be aligned right behind the first and the third textbox right behind the second which will take all the remaining space. I tried all sort of horizontal alignment but the spaces still persist and I start to be desperate - viz picture belove:
Thank you for your help.
Edit: the code here:
var group1 = settings.Items.AddGroupItem().FormLayoutGroup(1, Unit.Percentage(100), GroupBoxDecoration.Box);
... // other textboxes
var group2 = group1.Items.AddGroupItem().FormLayoutGroup(3, Unit.Percentage(100), GroupBoxDecoration.None);
group2.Items.Add(model => model.AdresaOsobyId.Adresa.Stat.ID).ToLambda(x =>
{
x.TextBox()
x.Width = 30;
x.HideCaption();
});
group2.Items.Add(model => model.AdresaOsobyId.Adresa.Psc).ToLambda(x =>
{
x.HideCaption();
x.TextBox();
x.Width = 60;
});
group2.Items.Add(model => model.AdresaOsobyId.Adresa.Posta).ToLambda(x =>
{
x.HideCaption();
x.TextBox();
});
Related
Using (jQuery Sortable) is it possible to populate the placeholder with the text containing the index of each item.
For instance if the user moves the mouse down to sort the value of the current index is shown in the box transitioning from and also the index is show in the box transitioning too.
For example we have a list, and the user drags the list item eq(1) the placeholder reveals the text in (1) and the relative index is shown in the above box either above or below.
If we have a list of three items:
List item 1;
List item 2; If the user moves up or down from the list item the placeholder is shown in box2 and box3 if moving downwards or box1 if moving upwards.
List item 3;
I can change the placeholder but cannot only to the current index.
I have tried the following:
start: function(event, ui){
//alert("X "+ui.item.index());
$(this).attr('data-previndex', ui.item.index());
ui.placeholder.css('color', '#999999');
ui.placeholder.css('font-size','26px');
ui.placeholder.html('Draw Number<br/>'+$(this).attr('data-previndex'));
},
update: function(event, ui){
var newIndex = ui.item.index();
var oldIndex = $(this).attr('data-previndex');
var element_id = ui.item.attr('id');
};
But the index always remains the same.
This post earlier is something similar to what I am trying to achieve:
text
I have a div (ItemsContainer) that has an array of items (Item) being rendered inside of it. The div has a dynamic size, depending on the size of the screen.
As I'm mapping through the array, I'd like to be able to make a check to see if there is enough space to render the current item. If there isn't, I'd like to stop rendering the items and instead add another item that says "+(number of items not rendered in array)". See the included picture for reference.
So far, this is what my code looks like. I'm using React typescript. I haven't attempted adding the "+5" box yet, because I'm wondering if it's actually possible? My initial thought is to just have a fixed number of items be displayed and then display the + item if there are more items not rendered, but I was hoping you could do it a bit more dynamic.
const Items: FC<Props> = ({ items }) => {
return (
<ItemsContainer>
{items.map((item, index) => (
<Item key={index}>{item.name}</Item>
))}
</ItemsContainer>
);
};
Here is a partially working solution: https://codepen.io/Latcarf/pen/WNKZmBN.
The main part of the code is the following:
const Tags = ({tags}) => {
const [hiddenCount, setHiddenCount] = React.useState(0)
const shownTags = hiddenCount == 0 ? tags : tags.slice(0, -hiddenCount);
const ref = React.useRef();
React.useLayoutEffect(() => {
if (!ref.current) {
return;
}
if (ref.current.scrollWidth > ref.current.clientWidth) {
setHiddenCount(count => count + 1);
}
});
return (
<div class="container" ref={ref}>
{shownTags.map(tag => <div class="tag">{tag}</div>)}
{hiddenCount > 0 && <div class="tag">{`+${hiddenCount}`}</div>}
</div>
)
};
The idea is to keep a hiddenCount state variable that contains the number of hidden tags. It starts at 0, and then a layout effect checks whether there is space and keeps incrementing it until there is enough space. It's a bit inefficient if you have many hidden items, as it will rerender many times until it reaches the correct amount, but it should properly deal with edge cases like if adding +1 would actually be longer than displaying the last tag, or stuff like that.
In order to make it update automatically on resize, you would use some kind of useResizeObserver hook to reset hiddenCount to 0 after a resize. Somehow I couldn’t manage to import other packages in CodePen, so I just made a button that forces a rerender so that you can test it (resize the div and then click the button).
Using a bar chart: https://developers.google.com/chart/interactive/docs/gallery/barchart when you have a lot of data, it crushes the bars to be very thin and the text to overlap each other. What options are there to get the data to render in the container properly (maybe guarantee each bar to be of a certain height if possible)? I want to avoid explicitly setting the height to say "1000px", then looking at the bar chart to determine whether it is scrunched up or not.
You can calculate a height for your BarChart dynamically, based on the number of rows of data in your DataTable:
// set inner height to 30 pixels per row
var chartAreaHeight = data.getNumberOfRows() * 30;
// add padding to outer height to accomodate title, axis labels, etc
var chartHeight = chartAreaHeight + 80;
var chart = new google.visualization.BarChart(document.querySelector('#chart_div'));
chart.draw(data, {
height: chartHeight,
chartArea: {
height: chartAreaHeight
}
});
I'm trying to control two containers using only one scrollbar. I have a large container that I shift (using CSS translations) to reveal another container that is sticky to the screen and to the right side. You can see my experiment here:
http://codepen.io/anon/pen/ipaCI
What I want is to use only the outer scrollbar (which controls the big and large div) to scroll both. I'm not looking for any synchronized scrolling, I want the scrollbar to first scroll the small container to the right, and when it's reached the end I want it to scroll the big container to the left.
I've experimented with trying to set a overflow-y: scroll on the body that contains both of these - but I can't seem to control the one on the right. Is it because it's fixed? If I make it positioned absolute it just follows like part of the page - which is not the desired effect.
Has anybody successfully implemented this kind of situation?
I have searched for plugins to do this but was unable to find any.
I've come up with a solution myself using jquery:
var $window = $(window),
$panel = $('.right-panel'),
windowPos = $window.scrollTop(),
scrollPos = $window.scrollTop(),
maxPos = $('.panel', $panel).height() - $window.height();
$window.on('scroll.panels-handler', function() {
var scrollDelta = $window.scrollTop() - windowPos;
windowPos = $window.scrollTop();
scrollPos += scrollDelta;
if (scrollPos < 0) {
scrollPos = 0;
} else if (scrollPos > maxPos) {
scrollPos = maxPos;
}
$panel.scrollTop(scrollPos);
});
I added a min- and max-scroll value for the container. Basically - it will always scroll the sidebar first - until it's reached its end - and then only the main window.
I couldn't figure out how to scroll only the sidebar (the main always scrolls) - but I'm satisfied with the solution.
See original codepen for a working demo
http://codepen.io/anon/pen/ipaCI
When using an editor like tinymce, how could i limit the height of the text a user enters so it doesn't use more space on the webpage than i want it to?
There are 2 things that i want some advise on:
In the editor:
The user enters text in a tinymce editor, he could set a text to font-size say 80px which would use up more space than a normal letter. So it's not the amount of text that i care about it's the height of the total.
In the webpage:
I don't want to give them more than say 200px worth of text on the page. But if they enter just 1 line of text with a small font-size i don't want to show a 200px space. So the height has to be flexible but with a maximum.
I know this isn't exact science but the goal here is to prevent the user from messing up the page.
To solve a similar issue i wrote the following function (placed inside an own tinymce plugin). You will need to add a variable for the maximum case and maybe tweak it a bit, but i hope this code will put you into the right direction
// this function will adjust the editors iframe height to fit in the editors content perfectly
resizeIframe: function(editor) {
var frameid = frameid ? frameid :editor.id+'_ifr';
var currentfr=document.getElementById(frameid);
if (currentfr && !window.opera){
currentfr.style.display="block";
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) { //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight + 26;
}
else if (currentfr.Document && currentfr.Document.body.scrollHeight) { //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
}
styles = currentfr.getAttribute('style').split(';');
for (var i=0; i<styles.length; i++) {
if ( styles[i].search('height:') ==1 ){
styles.splice(i,1);
break;
}
};
currentfr.setAttribute('style', styles.join(';'));
}
},