jQuery UI Widgets › Forums › Grid › How to set up dropDown of grid column programmatically
Tagged: dropdownlist editor
This topic contains 5 replies, has 2 voices, and was last updated by Peter Stoev 10 years, 10 months ago.
-
Author
-
Hello all,
This is the code:
var regrStates=[{value:"1",label:"+"},{value:"2",label:"-"},{value:"3",label:"<>"},{value:"4",label:" "}]; var regrSource={datatype:"array",datafields:[{name:"label",type:"string"},{name:"value",type:"string"}],localdata:regrStates}; var regrAdapter = new $.jqx.dataAdapter(regrSource, { autoBind: true }); $("$grid").jqxGrid({ source: dataAdapterT, editable: true, theme: theme, width: 255, columns: [{ text: 'Reg', width: 35, hidden: true, editable: true, datafield: 'regrCode', displayfield: 'Coeff', columntype: 'dropdownlist', createeditor: function (row, value, editor) { editor.jqxDropDownList({ source: regrAdapter, displayMember: 'label', placeHolder: '?', dropDownHeight: 105, valueMember: 'value' }); }, initeditor: function (row, cellValue, editor, cellText, width, height){ editor.jqxDropDownList('selectItem', cellValue); } }, { text: 'Factors', datafield: 'factors', width: 220, cellsrenderer: cellsrenderer, editable: false }] }); //reset grid dropdown function reset() { var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; var $grd = $("#grid"); $grd.jqxGrid('beginupdate'); for (var i = 0; i < rowscount; i++) { $grd.jqxGrid('setcellvalue', i, 'regrCode', 4); } $grd.jqxGrid('endupdate'); }
Function reset is supposed to set all dropdowns of the column to selected index 4. The result: the cell values are all set to value 4, but actual visible dropdown labels are not changed.
How can I reset all dropdowns to show some selected dropdown item, e.g. 1 or 3?
Thanks
Hi andy8,
You can change the value of an editor only in initeditor.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comPeter, still I don’t understand – is it possible to set up all dropdowns in a column programmatically? If yes, could you please share am example?
Hi andy8,
Let me try to explain you a few things about jqxGrid. Editor is opened when a cell enters into edit mode(usually after click, double click, etc). When the editor is created, the “createeditor” callback is called. “initeditor” is called each time the editor is opened again i.e when a new edit operation begins. In “initeditor” you should make your dynamic customizations about your editors. You cannot touch an editor outside “initeditor” and “createeditor” and you shouldn’t as well.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comOK, I understand that. Is there a way to enter an edit mode programmatically, i.e. without clicking the cell manually? I guess I could do it via begincelledit which will invoke the initeditor. Correct?
Hi andy8,
Yes, you can call “begincelledit” to put a cell in edit mode.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.