jQuery UI Widgets › Forums › Grid › Dynamic filter list work-around
Tagged: server-side
This topic contains 2 replies, has 1 voice, and was last updated by RedantJ 10 years, 2 months ago.
-
Author
-
Suppose you’re working with server side code, one column has first name [Mary, John, Mark, Ivan,…], one column has last name [Brown, Novak, Jensen, Horvat…]. If you were to select “Novak” in one column, all you want to see in the other column is [Filip, Jan]. I found one way to do this. On the server side, add an array to your JSON:
{ "firstName": [ "Filip", "Jan" ] }In your grid, before you declare your source:
var filterFirstName = new Array();Then when you make your source:
beforeprocessing: function(data) { if (data != null) { // From here, use : // filterFirstName.shift(); -- To remove the first item from the list // filterFirstName.unshift(data[x].firstName[i]); -- To add a new element to the beginning of the list // filterFirstName.push(data[x].firstName[i]); -- To add a new element to the end of the list // filterSchoolList.length = 0; -- Clears the list (as of this moment, I am not sure if this has any effect on garbage collection) // // filterFirstName.pop() doesn't seem to work. // Resetting the array to [] also doesn't work. } }…before adding it on to your grid:
{ text: 'First Name', datafield: 'firstName', displayfield: 'firstName', filtertype: 'checkedlist', filteritems: filterSchoolList, width: 200 },This is becoming a little frustrating:
beforeprocessing: function(data) { if (data != null) { filterFirstName.length = 0 var value1 = data[2].filterFirstName[0]; alert (value1); filterFirstName.unshift("AAA"); // This works filterFirstName.unshift(value1); // This doesn't } }I know I’m overlooking something pretty basic.
…and I was overlooking something basic!
This is the only code that I needed:
beforeprocessing: function(data) { if (data != null) { $('#jqxgrid').jqxGrid('setcolumnproperty', 'firstName', 'filteritems', data[2].filterFirstName); } } -
AuthorPosts
You must be logged in to reply to this topic.