<SCRIPT type = 'text/JavaScript '>
VaR editindex = undefined;
$ (Function (){
$ ('# Tb1'). DataGrid ({
URL: 'courseteacherssave. aspx? Opt = getdatagriddata & xnxq = '+ $ (' # hiddenxnxq '). val () + '& synj =' + $ ('# hiddensynj '). val () + '& bH =' + $ ('# hiddenbh '). val (),
Width: $ ('# tb1'). Parent (). Width (),
Height: $ (# tb1). Parent (). Height () * 0.85,
Fitcolumns: false,
Columns :[[
{Field: 'mkdm', hidden: true },
{Field: 'zwmc ', Title: 'account', width: 100, align: 'center '},
{Field: 'zgh', Title: 'instructor ', width: 300, align: 'center ',
Formatter: function (value, row) {return row. xm },
Editor :{
Type: 'combobox ',
Options :{
Valuefield: 'zgh ',
Textfield: 'xm ',
URL: 'courseteacherssave. aspx? Opt = getrkjsdata ',
Method: 'post ',
Multiple: True,
Onselect: function (record ){
If (record. zgh = ''){
VaR ED = $ ('# tb1 '). dataGrid ('getedit', {index: editindex, field: 'zgh'}); // obtain the index of the currently edited row.
Condition (ed.tar get). ComboBox ('settext ','');
Condition (ed.tar get). ComboBox ('setvalue ','');
}
}
}
}
}
],
Method: 'post ',
Onclickrow: onclickrow
});
$ ('# Btnqx'). Click (function () {parent. $ (' # add'). Window ('close ');});
$ ("# Btnsave"). Click (function (){
$ ('# Form'). Submit ();
});
$ ('# Form'). Form ({
URL: 'courseteacherssave. aspx? Opt = save ',
Onsubmit: function (){
If ($ (this). Form ('validate ')){
VaR rows = $ ('# tb1'). DataGrid ('getrows ');
For (VAR I = 0; I <rows. length; I ++ ){
VaR ED = $ ('# tb1'). DataGrid ('geteditor', {index: I, field: 'zgh '});
If (Ed! = NULL)
{
Rowsw.iw.{'xm'{}}(ed.tar get). ComboBox ('gettext ');
}
}
$ ('# Tb1'). DataGrid ('acceptchanges ');
$ ('# Hiddenstr'). Val (JSON. stringify ($ ('# tb1'). DataGrid ('getrows ')));
Loadmsg ("View ");
Return true;
} Else {
Return false;
}
},
Success: function (data ){
Loadmsg ('did ');
Data = jquery. parsejson (data );
If (data. isok ){
$. Messager. Alert ('hprompt ', Data. MSG, 'info', function () {parent. $ (' # add'). Window ('close ');}
)}
Else {$. Messager. Alert ('hprompt ', Data. MSG, 'info ');}
}
});
});
Function endediting (){
If (editindex = undefined) {return true}
If ($ ('# tb1'). DataGrid ('validaterow', editindex )){
VaR ED = $ ('# tb1'). DataGrid ('getedit', {index: editindex, field: 'zgh '});
$ ('# Tb1'). DataGrid ('enabled', editindex );
Editindex = undefined;
Return true;
} Else {
Return false;
}
}
Function onclickrow (INDEX ){
If (editindex! = Index ){
If (endediting ()){
$ ('# Tb1'). DataGrid ('selectrow', index)
. DataGrid ('ineinedit ', index );
Editindex = index;
} Else {
$ ('# Tb1'). DataGrid ('selectrow', editindex );
}
}
}
</SCRIPT>
Easyui DataGrid editor ComboBox clear ComboBox box