EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Alfred on May 04, 2017, 10:49:36 AM



Title: How can I implement datagrid in combobox formatter?
Post by: Alfred on May 04, 2017, 10:49:36 AM
I am looking for a way to implement datagrid inside combobox using the fomatter. I know that there is combogrid, but this combogrid could not work the way I expect.

   
Code:
$('.cc').combobox({
        url:'combobox_data.json',
        mode:'remote',
        valueField:'id',
        textField:'text',
        loader:myloader,
        formatter:function(row){
          return '<table class="dg" url="test.php?id="+row.id></table>';
        },
        onChange:function(n,o){
         //my other code
       }
    });

the datagrid code

   
Code:
$('.dg').datagrid({
        columns:[[
            {field:'code',title:'Code',width:100},
            {field:'name',title:'Name',width:100},
            {field:'price',title:'Price',width:100,align:'right'}
        ]]
    });

Please help.


Title: Re: How can I implement datagrid in combobox formatter?
Post by: jarry on May 04, 2017, 07:00:51 PM
Please refer to the code below:
Code:
$('#cc').combobox({
formatter: function(row){
return '<table class="dg" url="test.php?id="+row.id></table>';
},
onLoadSuccess: function(){
$(this).combobox('panel').find('.dg').datagrid({
height: 100,
columns: [[
{field:'code',title:'Code',width:100},
{field:'name',title:'Name',width:100},
{field:'price',title:'Price',width:100,align:'right'}
]]
})
}
})