jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Dropdown list not showing all values, and won't update
Tagged: dropdown, DropDownList, grid, values
This topic contains 4 replies, has 2 voices, and was last updated by Nigel 10 years, 1 month ago.
-
Author
-
Hi there, I’m fighting my way through implementing grids and I’m currently up against enumerated fields. My grid has a “Trade” column and it should be a dropdown based on values from my trades table.
I have a standard backend script that gets all the values and posts them back to an adapter:
var tradesource = { url : '/ajax/data/custom_jqxgrid_spec_item_trades.php', async: false, type : "POST", datatype : "json", datafields : [ { name : 'id', type : 'string' }, { name : 'name', type : 'string' } ] }; var tradesAdapter = new $.jqx.dataAdapter(tradesource, { autoBind : true } );
The non-async call causes a warning, but then I found this on another issue so I may be doing it wrong.
I can test I am proocessing all of the rows because I do this:
beforeLoadComplete: function (records) { var data = new Array(); for (var i = 0; i < records.length; i++) { data.push(records[i]); console.log(records[i]); } return data; }
All the values are listed.
I set this up as the values parameter in my grid:
{ name : 'trade_id', values: {source: tradesAdapter.records, value: 'id', name: 'name' } }
When I load the grid, I have 2 rows with different values and several blank rows. I click in the dropdown in any of the rows and I get only 4 entries. A blank row (not in the list sent back from the server), each of the populated values, and another blank value. but there are over 80 rows sent back.
What do I need to do to make this show all the values?
Also, When I change a value, the update code receives the text description, not the id value. How do I fix that?
Is there a demo for this?
For info, tradesAdapter.records has 88 rows in it, which is correct, and if I dump the values array at runtime, it has these in as the source… so why doesn’t it list all of them when the editor is required, and why doesn’t it pass pack the ID to the update function. Grrr.
Hi Nigel,
The built-in DropDownList editor lists the unique column values. For customization of the DropDownList editor’s source, look at: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/gridkeyvaluescolumnwitharray.htm?arctic
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Thanks Peter, I seem to have got it all working, and the dropdown sources are going back to the server to refresh each time I call them – perfect
For anyone else finding this, I had to use the createeditor function in the columns definition:
{
text : ‘Trade’,
datafield : ‘trade_id’,
columntype : ‘dropdownlist’,
createeditor : function(row, cellvalue, editor) {
editor.jqxDropDownList({
displayMember : ‘name’,
valueMember : ‘id’
});
}Oh, sorry, and the initeditor to point at the source
initeditor : function(row, cellvalue, editor) { editor.jqxDropDownList({ source : subcontractorsAdapter }); }
-
AuthorPosts
You must be logged in to reply to this topic.