showing top n options in a dropdownlist - asp.net

Consider an ASP.NET server control DropDownList (or <input type='select'>) with a large number of options (e.g. 100 options). When clicking on the list, the full list of 100 options are shown. They're all displayed, and run off the screen.
How can the control's picklist size be resized or limited to the first n options?

Frédéric Hamidi has already given the short answer, however he has also referred you to a perfect alternative. Explore this and that is similar to what I had done when I faced similar situation.
Idea is that you don't populate your list. This way your drop down will be empty and in place of that you show a div with scrollbar and whatever you wish. Align this div in such a way that user thinks, "it is the dropdown".

Related

gridview goes back to visible=false when page changes...(and page # issues)

Probably an easy and simple answer to this, but everywhere I look, the questions are more complicated than my situation...
I've got a gridview which is set to be visible false in the aspx. If a search returns results, it gets made "visible", however, if there's more than 10 results (set to 10 per page) and the user clicks on one of the page numbers at the bottom, it resets it's visibility to false. Is there any way around this, short of adding a panel for it to sit on? seems like there should be a way to do this without adding extra objects to the DOM.
Also, on a related note, those page numbers are spaced out in cells across the bottom, instead of being neatly lined up next to one another. Is there a simple pagerStyle setting that collects them all in a row? I've not seen a gridview do this before... in the past its default settings have always placed those numbers neatly in the lower left hand corner... any quick tips?

how to increase Drop Down List capacity in asp.net

How can you increase Drop Down List capacity in asp.net? I have to display 20,000 items in a single DropDownList but it not showing all items after binding. Some items are missing.
How can I achieve this?
I'm not aware of any direct limitation applied by the .NET framework; there may be a limit applied by the client, but I'm not sure. 20,000 is a lot of items and a lot of HTML to render, and HTML rendering is one of the bigger performance problems. You may want to instead consider an alternative approach like an AutoComplete feature, such as this.
There is no reason the dropdown list selection would be missing items.
Check your data source before binding to make sure all the items are there, it could be an issue with the query filling the data source rather than the dropdown list missing items.
Though as people have pointed out, replace this with either a search function or a autocomplete function dropdown lists should not be a place for 20,000 items.

Auto Complete Extender for multiline textbox - Facebook style

I have in my application a larger textbox and offer user the possibility to enter text on several rows like this:
first piece of text
second piece of text
and so on...
Each row is a distinct piece of data that has a significance. The thing is I would like to use ajax auto complete extender functionality after the user types a certain character on a row, such as #, and filter the records in the database according to the first letter the user typed after #, moment when the auto complete suggestion list would appear. For example, third piece of text #Action1, means that after the user typed A he would be prompted with a list of values to choose from.
There are several items of concern for me: first, it is possible to use autocomplete extender only for part of the text in the textbox, and second does it work like this for multiple rows (i.e. one time - in each line behaviour)? Regarding its position, I guess I have no other choice than at the bottom of the textbox it refers to, despite I would have liked it to appear below the # symbol.
Thank you very much.
Update: I found something similar to what I am looking for here: Twitter-style autocomplete in textarea, but the author only explained briefly his solution. Any help much appreciated, thx!
Each row is a distinct piece of data that has a significance.
Why are you using a textarea then, and not multiple <input> fields?
Sounds to me like your error in UI design lies right there already, so the rest of my answer is rather theoretical; I probably won’t go into more details as the sensible fix for your problem is the one above.
first, it is possible to use autocomplete extender only for part of the text in the textbox,
Why shouldn’t it be? Cursor position in a textarea for example is readable (although it requires some working around cross-browser issues).
and second does it work like this for multiple rows (i.e. one time - in each line behaviour)?
So long as the line breaks are “hard” ones (made by the user themselves, using enter/return), splitting the actual textarea content by "\n" to have each row as a single value is no problem.
Regarding its position, I guess I have no other choice than at the bottom of the textbox it refers to, despite I would have liked it to appear below the # symbol.
You could try to roughly measure the #’s position, by line and col number it is on, and match that to the character width and line height, when using a monospace font. For other fonts, some more “magic” might be required to measure the actual width of the previous text before the # character.
I have created a Meteor package for this, which allows both free text and multiple autocomplete sources. Meteor's data model allows for fast multi-rule searching with custom rendered lists. If you're not using Meteor for your web app, (I believe) you unfortunately won't find anything this awesome for autocompletion.
https://github.com/mizzao/meteor-autocomplete
See the link for pictures of how it works. Fork, pull, and improve!

How to show only 30 rows and hide the remaining rows of QTableWidget

I'm having a QTableWidget with 10,000 records. I need to show only 30 rows at a time and hide the remaining rows. While dragining/clicking vertical scrollbar it should show corresponding rows and hide the other rows.
ie, if one clicks on upper scroll button it should show one more upper item and hide one lower item and vice versa. It should happen while scrolling as well.
Can anyone help me in doing this?
I think you can trap the events of up/down buttons as Nicholas said, for the tracking of slider/scroll bar u need use 'setTracking(true)'followed by the handling of signal either 'valueChanged(int)' or 'sliderMoved(int)'.
Thanks,
Pradeep
Qt unfortunately won't make this easy for you, there is ways and means of doing it however. Depending on how you're populating your widget I'd recommend setting it up so you initially populate your 30 rows, you then need to trap the signals coming from the scroll buttons being clicked and tell the table widget to remove the upper/lower item and add the next one, there's trade off's to this method, but it'll make it easier than trying to maintain a large list of hidden rows.
I don't know if explicitly showing/hiding things is the way you want to go. Instead, take a look at Qt's model and view classes. If you are using a database, have a look at QSqlTableModel, which should handle these things for you. Otherwise, have a look at the Model-View programming document, their related examples, and especially the portion about optimizing for performance (although in a model, 10,000 records isn't really all that many for most uses).
There is a way to change table scrolling from pixels to items. In Designer Property Editor for the table, in the QAbstractItemView section, there is a VerticalScrollMode selection. This can either be ScrollPerPixel or what you probably want, ScrollPerItem.
That may change the behavior of the signal from pixels to items which would make your calculations easier.
I'm using 4.4.3.

Dropdownlist - number of display element

I have dropdownlist on my webpage.
When I click it the list with all items is expanded. But this list is very long.
How can I change it to achievie a list with (e.g.) 5 displayed items and with a scrollbar next to them.
If it is not possible, how can I do it with ListBox? I know it is Rows property there but can I declare how many rows is display all the time not after expanding the list.
This control, will, of course be rendered on the page as a standard <select> control.
With these, the height of the list once its dropped down is determined by the browser, and you have no control over this. You'll notice when the list approaches the foot of the page, the browser will implement the scrollbar as you suggested, but not with the number of items you maybe want.
My only suggestion would be to investigate the options offered by some client-side drop down add-ins. You may be able to find some jQuery ones that will help.
A simple google search for "jquery dropdowns" yielded this article as the top result: 38 jQuery And CSS Drop Down Multi Level Menu Solutions. If you can't find something here then there are also plenty similar sites in the search results.
I think this post provides you with a couple of different solutions to your problem.
http://blogs.msdn.com/b/rakkimk/archive/2011/05/02/dropdownlist-html-select-vertical-scrollbar-number-of-items.aspx

Resources