jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Grid combobox editor change another property in the same row
Tagged: grid, jquery grid, jqxgrid
This topic contains 3 replies, has 2 voices, and was last updated by martonx 12 years, 2 months ago.
-
Author
-
Hi,
I have a grid with a combobox editor. dname and dnumber are two column which I want to change with a combobx’s label and value. I would like to use combobox for change the “comboboxed” column with combobox selected item’s label, and change another column with combobox selected item’s value. Here you are part of my code:
columns: [
{ text: ‘Id’, datafield: ‘id’, width: 170 },
{ text: ‘Szám’, datafield: ‘dnumber’, width: 170 },
{ text: ‘Név’, datafield: ‘dname’, width: 200, columntype: ‘combobox’,
createeditor: function (row, column, editor) {
editor.jqxComboBox({ source: DolgozoAdapter, displayMember: “name”, valueMember: “number” });
editor.bind(‘select’, function (event) {
var item = event.args.item;
if (item) {
var value = item.value;
var label = item.label;
TestIndex = value;
}
});
},
cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
if (newvalue == “”) return oldvalue;
}
}
]And here it is the grid’s source updaterow method:
updaterow: function (rowid, rowdata, commit) {
var data = ‘update=true&id=’ + rowdata.id + ‘&dnumber=’ + rowdata.dnumber.trim() + ‘&dname=’ + rowdata.dname;
$.ajax({
dataType: ‘json’,
url: ‘/Home/UpdateKapcsolat’,
data: data,
type: ‘POST’,
success: function (data, status, xhr) {
commit(true);
},
error: function (jqXHR, textStatus, errorThrown) {
commit(false);
}
});
}This code is working, so I populate with remote datas the combox, I can select from items, I can change dname column. But I need to change dnumber column too, because that is the foreign key.
Please help me!
Thank you very much!
Lajos
Hi,
For defining Foreign Key Column, please take a look at the following samples:
– http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/gridkeyvaluescolumnwitharray.htm?web
– http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/gridkeyvaluecolumn.htm?webBest Wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
I made a workaround, but it’s not 100%.
{ text: ‘Név’, datafield: ‘dname’, width: 200, columntype: ‘combobox’,
createeditor: function (row, column, editor) {
editor.jqxComboBox({ source: DolgozoAdapter, displayMember: “nev”, valueMember: “dszam” });
editor.bind(‘select’, function (event) {
var item = event.args.item;
if (item) {
TempValue = item.value; //TempValue is global variable
}
});
},
cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
if (newvalue == “”) return oldvalue;
Grid.jqxGrid(‘setcellvalue’, row, “dnumber”, TempValue);
}
}It seems working, server side updates the database, just in the console I got this error: Uncaught TypeError: Cannot call method ‘focus’ of undefined.
I think when I’m in edit mode in the dname cell, the code want to move focus into dnumber cell. How can I avoid this console error?
How can I set cell value without this focus error?Please advice,
LajosPeter,
I need something like your second linked example. But I need added a feature, when I change the City in a combobox, or dropdown, the grid should change the Country column. I hope you understand what do I mean? When I change Lyon to Rio de Janeiro, the Country should change to Brasil from France.
In my code, I do this, with those javascript error.
Could you make an example for this?Thank you very much,
Lajos
-
AuthorPosts
You must be logged in to reply to this topic.