数据网格easyui中的依赖组合框

时间:2014-11-21 06:55:01

标签: javascript jquery datagrid combobox jquery-easyui

我使用easyui但不能正常工作的数据网格中的组合框

},{
  field: "family", 
  title: "Family", 
  align: "center",
  width: 150, 
  editor: {
    type: "combobox",
    options: {
      valueField :"family_id",
      textField :"family",
      url:'<?php echo site_url(); ?>/ref_json/DataFamily',
      onSelect: function(rec){ 
        var url = '<?php echo site_url(); ?>/ref_json/DataMaterial1/'+rec.family_id; 
        var ed = $('dgUpholdstery').datagrid('getEditors',{index:1,field:'material'});
        $(ed.target).combobox('reload',url);
      },
      filter: function(q,row){
        return row.family.toLowerCase().indexOf(q.toLowerCase())==0;
      }
    }
  }
},{
  field: "material", 
  title: "Name", 
  align: "center",
  width: 270, 
  editor: {
    type: "combobox",
    options: {
      valueField:"kode_barang",
      textField:"nama_barang",
      url:'<?php echo site_url(); ?>/ref_json/DataMaterial1'
    }
  }
},{

我已经测试过许多其他变化,但没有任何反应。请帮我。我是这样堆叠的。 谢谢你的帮助。

1 个答案:

答案 0 :(得分:3)

我刚用这段代码解决了这个问题

....
onSelect: function(rows){ 
    var url = '<?php echo site_url(); ?>/ref_json/DataMaterial1/'+rows.family_id; 
    var tr = $(this).closest('tr.datagrid-row');
    var idx = parseInt(tr.attr('datagrid-row-index'));
    var ed = $("#dgUpholdstery").datagrid("getEditor", {index:idx, field:'kode_barang'});       
    $(ed.target).combobox("reload", url);
}
....