EasyUI Forum
May 08, 2024, 06:03:39 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: using dependent combobox in datagrid  (Read 50714 times)
cyber_dy
Newbie
*
Posts: 4



View Profile Email
« on: September 30, 2012, 08:58:36 PM »

hello,,
help me
how to make  dependent  combobox in datagrid editing ??

best regars,
Logged
Kevin
Jr. Member
**
Posts: 52


View Profile Email
« Reply #1 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
Logged
cyber_dy
Newbie
*
Posts: 4



View Profile Email
« Reply #2 on: October 01, 2012, 08:06:13 PM »

thank you for your replay,
i'm sorry if my english so bad Sad
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,
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: October 02, 2012, 06:03:34 PM »

Please refer to this topic http://www.jeasyui.com/forum/index.php?topic=559.0
Logged
cyber_dy
Newbie
*
Posts: 4



View Profile Email
« Reply #4 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,

« Last Edit: October 03, 2012, 09:36:17 PM by cyber_dy » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 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)
Logged
cyber_dy
Newbie
*
Posts: 4



View Profile Email
« Reply #6 on: October 08, 2012, 06:09:36 PM »

it solved,
thank you stworthy
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!