How can I clear the current results in Select2 4.0.5 before displaying a new result set? - jquery-select2

I populate the Select2 data dynamically using the Query function on opening. Everything is fine except the fact that on the second and further opening first you see the previous results for a short time. How can I clear them properly before opening Select2? Nothing helps.

Related

Zkoss listbox+frozen+hide_column

I use listbox with one frozen column. it's working fine but if i hide last (only last) column , i'll get problem with listbox's content. Header scrolls normaly but all rows of listbox appear.
ZK-8.5.2.1-Eval
I use olde frozen - listbox.setAttribute("org.zkoss.zul.frozen.smooth", false);
I'd suggest to try the latest version ZK 8.6.0.1 first? The release notes (8.6.0 / 8.6.0.1) indicate errors being fixed regarding frozen and listheaders maybe the problem doesn't happen anymore with the latest version.
It the problem still exists it would help if you can provide a reproducing/runnable example e.g. on zkfiddle.org Please, save and post the link or url-path here.

Loading select options after setting value

My program flow requires that I first set the value of a select option in the Viewmodel and then I load the available options into the Viewmodel. This causes problems, typically the first available option will be seen in the selection list after this, while the selected option value stays at the specified value.
I was hoping that setting the new "valueAllowUnset" would help, but instead my page becomes unresponsive when using it.
Therefore I currently set the original value again after loading the options. Strangely, this only works when I set the value, set a different value and then set the value again, e.g.
self.data()[field](orgValue);
self.data()[field]({});
self.data()[field](orgValue);
(I store values for multiple selection lists in the self.data observable and access them with the property index "field".)
I tried to strip this down to a simple JSFiddle (http://jsfiddle.net/timvdh/HN6DE/), but the behavior does not show there, although the example pretty much resembles my actual application. However, I am using about 30 select lists there.
So I was hoping, that someone can make an educated guess about what goes wrong in my application, I am hoping that the fact that I have to set the original value three times maybe gives a clue.
EDIT: This fiddle demonstrates, that setting the selected option before and after filling the options list does work with "valueAllowUnset": http://jsfiddle.net/timvdh/HT5Tp/
I am using JQuery Mobile with knockout.js and that caused the problem (sorry I did not even think about JQM being the problem in the first place). I am now setting the option before filling the list and after filling the list I call
$("#selectmenuID").selectmenu("refresh");
to display the option.
The hanging browser was not caused by knockout, there are additional subscriptions to the selectmenus in my app. "valueAllowUnset" changed the behavior of the selectmenus and triggered loops caused by problems in my code.

smartgwt filter editor problem

i am using Listgrid of smartgwt api. i have set filter editor on the list grid using setShowFilterEditor(). On UI, i can filter out the text from the particular columns using filter editor which is shown on top of listgrid. till this, everything works fine. but problem starts after this. my ListGridRecords are of type ScreenInstanceGridRecord.
I cleared out the filter criteria before getting the ListGridRecord from the ListGrid using method clearCriteria(), so that i can save all the records to database ie. unfiltered records. when i try to get records from the listgrid using getRecordList(), 1000 Dummy records are added on the fly on first iteration, all my populated records are ignored . and i need here is records of ScreenInstanceGridRecord type. but on second iteration, i am getting my populated records which is of ScreenInstanceGridRecord type. why this problem is occurring. i should be getting ScreenInstanceGridRecord on the first iteration itself when i try to get records from the ListGrid using getRecordList(). i am getting no idea about this weird thing. any help from your side is most welcome.. plss
When you say you're getting 1000 Dummy records instead of your loaded records, in fact, your Records are not loaded yet at all. In this case, the ResultSet created by the ListGrid (see docs for ListGrid.fetchData()) is returning a provisional length (defaults to 1000) and returning the loading marker in lieu of Records (see ResultSet.rowIsLoaded()).
Use the DataArrived event to take action once data has been loaded. See ResultSet.lengthIsKnown() for how you can, in general, tell that data is not yet loaded.

Telerik Grid (MVC) does not display returned JSON

I have a telerik MVC grid. After making some changes to the underlying code, the grid no longer shows the results returned from the server. I can see the correctly formatted JSON return from the server (using functionality from Web Developer Toolbar), but the grid never actually shows the data. However, it also doesn't generate an error. The loading icon just keeps spinning.
Does anyone have a suggestion on how to localize the problem? Thanks.
EDIT
Well, I managed to get a step further. Apparently something goes wrong in the "bindData"-function located in telerik.grid.js. More specifically in line 462:
460. var evaluate = column.display;
461. if (evaluate)
462. html.cat(evaluate(data[rowIndex]));
When trying to render the last column in the first row, evaluate is set to anonymous and somehow, this results in an "invisible" exception. The markup of this column is:
columns.Bound(c => c.DocumentId)
.ClientTemplate("<a href=\"" + Url.Content("/") +
"/document/<#= DocumentId #>\" target=\"_blank\"><#= Naam #></a>")
.Filterable(false)
.Title("Naam");
I don't understand why this would be a problem, as I use similar templates elsewhere without any problem.
EDIT
Ok, I got it. Apparently some exceptions will not be shown in the Firefox/Firebug console. However, Visual Studio together with IE do not have this problem. I finally discovered that indeed the field "Naam" was missing in the IEnumerable.
So something to take away here is never to trust the results from just one browser ;-)
I had a similar behaviour recently when I had changed the type that the grid was expecting.
Make sure that your ajax call is returning the correct IEnumerable that is specified in the grid markup.
You need to post code for the GridAction and markup if you want a more accurate answer.

Save Conflict Error when trying to add new List Items at the time of list creation

We have created a Custom List template programmatically using Feature.xml, Element.xml, Schema.xml AllItems.aspx, and 3 aspx forms. We have a code behind file for each of these aspx files. i.e. for the AllItems.aspx, DispForm.aspx, EditForm.aspx and NewForm.aspx.
Problematic file is AllItems.aspx. In the code behind for AllItems.aspx file we are deleting previous list items and adding new items to the list before showing them up to the user. As per expectations the code behind file for AllItems.aspx is derived from WebPartPage Class and we have tried to overload quite a few methods without much success.
Problem only occurs on the first time rendering i.e. when an instance of this list is created. When overriding OnLoad(), we get the Save conflict error, Similar is the case with OnInit(), CreateChildControls() method. However, when we override the Render() or RenderChildren() method no such error comes up but at the same time our new list items are also not visible. On browser refresh everything starts working fine as expected. It is only for the first time that the issue comes up.
What could be the possible cause for this? Any ideas, suggestions would be highly appreciated.
Best Regards,
Raghu
I had a problem with a custom EditForm.aspx. I have two lists that are linked together and a change in one causes an event handler to update the other. I have a custom control in EditForm.aspx that edits the linked list. This was causing the event handler to update the item displayed by EditForm.aspx. This in turn would cause the conflict error when the user saved the form.
I finally found that I could reset the context with:
SPContext.Current.ResetItem();
I am not sure if this will help in your case but it fixed my problem.

Resources