随笔《获得easyui datagrid combobox下拉框的数据》

 //第一种获取datagrid的方法
/* var tidd = $('#teachertb').datagrid('getEditor', {index:editIndex,field:'tid'});
var tid = $(tidd.target).val();

var tnamed = $('#teachertb').datagrid('getEditor', {index:editIndex,field:'tname'});
var tname = $(tnamed.target).val();

var tdeptnamed = $('#teachertb').datagrid('getEditor', {index:editIndex,field:'tdeptname'});
var tdeptname = $(tdeptnamed.target).val();

var tpostnamed = $('#teachertb').datagrid('getEditor', {index:editIndex,field:'tpostname'});
var tpostname = $(tpostnamed.target).val();

var tdegreenamed = $('#teachertb').datagrid('getEditor', {index:editIndex,field:'tdegreename'});
var tdegreename = $(tdegreenamed.target).val();


var teacher={tid:tid,tname:tname,tdeptname:tdeptname,tpostname:tpostname,tdegreename:tdegreename};
*/
 
 
var ed = $('#teachertb').datagrid('getEditor', {index:editIndex,field:'tdeptname'});
var tdeptname = $(ed.target).combobox('getText');

 
 
 
 
//第二种获取datagrid数据的方法
var $obj = $('#teachertb');
var node = $obj.datagrid('getSelected'); 


//第三种获取datagrid的方法
//获取修改行的所有数据
var rows = $('#teachertb').datagrid('getRows');
         //获取修后该行所有field的值,在这里将修改后数据写入到数据库中
      var rowData = rows[editIndex];  
         
         var tid=rowData.tid;
         var tname=rowData.tname;
       //var tdeptname=rowData.tdeptname;
         var tpostname=rowData.tpostname;
         var tdegreename=rowData.tdegreename;   
  var teacher={tid:tid,tname:tname,tdeptname:tdeptname,tpostname:tpostname,tdegreename:tdegreename};


var json = {};  
        json.tid = rowData.tid;  
        json.tname = rowData.tname;  
        json.tdeptname = rowData.tdeptname;  
        json.tpostname   = rowData.tpostname;  
        json.tdegreename  = rowData.tdegreename;  
 
 
var teacherjson=$.toJSON(teacher);

没有更多推荐了,返回首页