EasyUI Forum

General Category => General Discussion => Topic started by: cyber_dy on September 30, 2012, 08:58:36 PM



Title: using dependent combobox in datagrid
Post by: cyber_dy on September 30, 2012, 08:58:36 PM
hello,,
help me
how to make  dependent  combobox in datagrid editing ??

best regars,


Title: Re: using dependent combobox in datagrid
Post by: Kevin on October 01, 2012, 04:56:56 PM
If I understand your question correctly, then check out the source for the following demo;
http://www.jeasyui.com/tutorial/datagrid/datagrid12_demo.html


Title: Re: using dependent combobox in datagrid
Post by: cyber_dy on October 01, 2012, 08:06:13 PM
thank you for your replay,
i'm sorry if my english so bad :(
yes i means like this example
http://www.jeasyui.com/tutorial/datagrid/datagrid12_demo.html#
but i will use dependent comboboxes
how to Create two or three dependent comboboxes.

best regars,


Title: Re: using dependent combobox in datagrid
Post by: stworthy on October 02, 2012, 06:03:34 PM
Please refer to this topic http://www.jeasyui.com/forum/index.php?topic=559.0


Title: Re: using dependent combobox in datagrid
Post by: cyber_dy on October 03, 2012, 09:30:24 PM
hai stworthy  
thank you for your reaply
here my code..
i use datagrid not edatagrid
Code:
$(function(){
                $('#tt').datagrid({
                    title:'Editable DataGrid',
                    iconCls:'icon-edit',
                    width:660,
                    height:250,
                    singleSelect:false,
                    showFooter:true,
                    idField:'itemid',
                    //url:'data/datagrid_data.json',
                    columns:[[
                            {field:'ck',checkbox:true},
                            {field:'itemid',title:'Item ID',width:60},
                            {field:'productid',title:'Product',width:100,
                                editor:{
                                    type:'combobox',
                                    options:{
                                        mode:'remote',
                                        valueField:'productid',
                                        textField:'name',
                                        url:'comboboxs.php',
                                        required:true,
                                        onChange:function(newValue, oldValue) {                                       
                                            ede = $("#tt").datagrid("getEditor", {index: 0, field:"kota"});
                                         //   alert(ede.toSource());
                                            $(ede.target).combobox("setValue", newValue-1);
                                            // getEditor
                                        }
                                    }
                                }
                            },
                            {field:'kota',title:'kota', width:80, editor:{
                                    type:'combobox',
                                    options:{
                                        valueField:'productid',
                                        textField:'name',
                                        data:[
                                            {productid: 1, name: "satu"},
                                            {productid: 2, name: "dua"},
                                            {productid: 3, name: "tiga"},
                                        ],
                                        required:true
                                    }
                                }
                            },
                            {field:'unitcost',title:'Unit Cost',width:80,align:'right',editor:'numberbox'},
                            {field:'attr1',title:'Attribute',width:180,editor:'text'},
                            {field:'action',title:'Action',width:80,align:'center',
                                formatter:function(value,row,index){
                                    if (row.editing){
                                        var s = '<a href="#" onclick="saverow(this)">Save</a> ';
                                        var c = '<a href="#" onclick="cancelrow(this)">Cancel</a>';
                                        return s+c;
                                    } else {
                                        var e = '<a href="#" onclick="editrow(this)">Edit</a> ';
                                        var d = '<a href="#" onclick="deleterow(this)">Delete</a>';
                                        return e+d;
                                    }
                                }
                            }
                        ]],
                    toolbar:[{
                            text:'Add',
                            iconCls:'icon-add',
                            handler:function(){
                                insert()
                            }
                        }],
                    onBeforeEdit:function(index,row){
                        row.editing = true;
                        updateActions(index);
                    },
                    onAfterEdit:function(index,row){
                        row.editing = false;
                        updateActions(index);
                    },
                    onCancelEdit:function(index,row){
                        row.editing = false;
                        updateActions(index);
                    }
                });
            });
            function updateActions(index){
                $('#tt').datagrid('updateRow',{
                    index: index,
                    row:{}
                });
            }

in my code i can't get index of editor,,
how to get index of row editor,,??
thanks,



Title: Re: using dependent combobox in datagrid
Post by: stworthy on October 04, 2012, 06:02:22 AM
On the 'onChange' event of combobox, call the following code to get the row index.
Code:
var tr = $(this).closest('tr.datagrid-row');
var index = parseInt(tr.attr('datagrid-row-index'));
alert(index)


Title: Re: using dependent combobox in datagrid
Post by: cyber_dy on October 08, 2012, 06:09:36 PM
it solved,
thank you stworthy