jQuery UI Widgets › Forums › Grid › initeditor combobox source
Tagged: #combobox, createeditor, custom, editor, grid, initeditor, jqxComboBox, jqxGrid ;, source, update
This topic contains 1 reply, has 2 voices, and was last updated by Stanislav 6 years, 11 months ago.
-
Author
-
I have a combobox inside a jqxgrid,
When a new item is added to the combobox it is not updatedmy code:
var grid = jQuery("#tablePreviousYear"); console.error("======== C"); console.error(baseYearCombobox); var source = { datatype: "json", datafields: [ //-- Passa os Ids que serão usados para os updates {name: 'Openingyearid', type: 'int'}, {name: 'Name', type: 'string'}, {name: 'Year', type: 'int'}, {name: 'Fpe', type: 'string'}, {name: 'Openingyearbaseid', type: 'int'}, {name: 'baseYear', type: 'int'} ], localdata: items }; var cellclass = function (row, columnfield, value) { // Pega a linha que está sendo "construída" var item = grid.jqxGrid('getrowdata', row); //-- if (!item.Openingyearid) {return 'color';} }; var dataAdapter = new jQuery.jqx.dataAdapter(source); grid.jqxGrid({ width: "100%", height: 200, filterable: true,//-- FILTRO showfilterrow: true,//-- FILTRO editable: true,//-- EDITADO enabletooltips: false, columnsresize: true,//-- MEXER NO TAMANHO DAS COLUNAS selectionmode: 'singlecell',//-- MODO DE SELECAO sortable: true, source: dataAdapter, columns: [ {datafield: 'Name', text: translate_lang.global.school, width: '50%', filterable: false, editable: false,cellclassname: cellclass}, {datafield: 'Year', text: translate_lang.global.year, width: '10%',cellclassname: cellclass,}, {datafield: 'Fpe', text: translate_lang.global.fpe, width: '10%', filterable: false,cellclassname: cellclass,}, {width:"10%",text: translate_lang.global.base_year, datafield: 'Openingyearbaseid', displayfield: 'baseYear', columntype: 'combobox',cellclassname: cellclass, //-- CRIA O COMBO createeditor: function (row, column, editor) { editor.jqxComboBox({autoDropDownHeight: true,source: baseYearCombobox, theme: 'fresh', displayMember: 'description', valueMember: 'id' }); }, initeditor: function (row, cellvalue, editor, celltext, pressedkey) //-- INCIIA TODA VEZ QUE A CELULA É CLICADA { console.error("======== I"); console.error(baseYearCombobox); editor.jqxComboBox({ source: baseYearCombobox }); }, cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { // return the old value, if the new value is empty. if (newvalue == "") return oldvalue; } /*geteditorvalue: function (row, cellvalue, editor) { // editor.jqxComboBox({ source:cellvalue}); }*/ }, {width:"10%", columntype: 'string', text: translate_lang.current.duplicate, filterable: false, editable: false, groupable: false, cellclassname: cellclass, cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { defaulthtml = '<div onClick="replicateClass('+row+')" title="Replicar" style="cursor: Pointer;width: 100%; height: 100%; text-align: center"><i class="fa fa-files-o fa-lg" style="color: #3F3F3F;font-weight: bold;margin-top: 5px;"></i></div>'; return defaulthtml; } }, { columntype: 'string', text: translate_lang.global.save, width: '10%', filterable: false, editable: false, groupable: false, columnsresize: true, cellsalign: 'center', align: 'center', cellclassname: cellclass, cellsrenderer: function (row, columnfield, value, defaulthtml) { var rowData = grid.jqxGrid('getrowdata', row); var icon; if(rowData.Openingyearid) {icon = "fa-pencil";} else {icon = "fa-floppy-o";} defaulthtml = '<div onClick="saveOpeningYear(' + row + ')" title="'+translate_lang.global.save+'" style="cursor: Pointer;width: 100%; height: 100%; text-align: center"><i class="fa '+icon+' fa-lg" style="color: #3F3F3F;"></i></div>'; return defaulthtml; } }] });
Print Console:
======== C
0: {id: “62”, description:”2017″}
1: {id: “63”, description:”2016″}======== C
0: {id: “62”, description:”2017″}Hello Perez,
This demo shows how to addItems to jqxComboBox.
AddItem to ComboBoxAfter adding the item you should update/refresh the Grid aswell.
Refresh the GridBest Regards,
StanislavjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.