以下是我的行的一部分。当组合框值更改时,我需要更改BudgetLineItemCode字段的值。
{ title: 'Index', field: 'RootLevel', width: 50, editor: { 'type': 'validatebox', 'options': { required: true}} },
{ field: 'PHeading', title: 'Heading', width: 240,
formatter: function (value) {
for (var i = 0; i < CItems.length; i++) {
if (CItems[i].heading.toLowerCase() == value.toLowerCase()) {
return CItems[i].heading;
}
return value;
},
editor: {
type: 'combobox',
options: {
valueField: 'heading',
textField: 'heading',
data: CItems,
required: true
onSelect: function (record) {
var selrow = $('#trgrid').treegrid('getSelected');
var rowIndex = $('#trgrid').treegrid('find',row.BudgetDetailID)
var editors =$('#trgrid').treegrid('getEditors',selrow.BudgetDetailID);
var codeEditor = editors[2];
$(codeEditor.target).text('setValue', 'newval');
}
}
}{ title: 'Code', field: 'BudgetLineItemCode', width: 50, editor: { 'type': 'text'} }
另外, 还有一个问题。组合框没有onChange事件。我们有什么办法可以解决这个问题。我的意思是,我可能想要检查代码作为组合框中的用户类型。
答案 0 :(得分:2)
第一部分你可以做
$(codeEditor.target).val('newval');
因为validatebox的setter是.val(),
docs here ..
并且对于第二个easyui组合框默认执行此操作..或者您可以使用keyhandler
editor: {
type: 'combobox',
options: {
valueField: 'heading',
textField: 'heading',
data: CItems,
required: true,
keyHandler: {
up: function(){},
down: function(){},
enter: function(){},
query: function(q){ console.log(q)} //<----here
},
onSelect: function (record) {
var selrow = $('#trgrid').treegrid('getSelected');
var rowIndex = $('#trgrid').treegrid('find',row.BudgetDetailID)
var editors =$('#trgrid').treegrid('getEditors',selrow.BudgetDetailID);
var codeEditor = editors[2];
$(codeEditor.target).text('setValue', 'newval');
}
}
答案 1 :(得分:0)
<强>代码:强>
onSelect: function(rec){
var row = $('#tblCoursefaculty').datagrid('getSelected');
var rowIndex = $('#tblCoursefaculty').datagrid('getRowIndex', row)
var editors = $('#tblCoursefaculty').datagrid('getEditors', rowIndex);
var ed_fc_co_section = editors[8];
$(ed_fc_co_section.target).val(rec.co_section);
var ed_fc_co_course_cr = editors[9];
$(ed_fc_co_course_cr.target).val(rec.co_course_cr); }
} }">Course</th>
<th data-options="field:'fc_co_section',width:50,align:'left',editor:'text'">Section</th>
<th data-options="field:'fc_co_course_cr',width:50,align:'left',editor:'text'">Credit Hour</th>