EasyUI Forum
April 29, 2024, 05:59:09 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Display remote combobox item in edatagrid loaded  (Read 10028 times)
finzaiko
Newbie
*
Posts: 44


View Profile
« on: September 25, 2013, 01:02:19 AM »

I tried from example edatagrid12 load combobox item from remote server and read this topic http://www.jeasyui.com/forum/index.php?topic=1896.0
I want to display the name of the supplier and not ID of supplier when edatagrid loaded,
 
Code:
$('#inv').edatagrid({
            url: 'index.php?r=invoice/getData',
            saveUrl: 'index.php?r=invoice/create',
            updateUrl: 'index.php?r=invoice/update',
            destroyUrl: 'index.php?r=invoice/delete',
            onClickRow: function() {
                invid = $('#inv').datagrid('getSelected');
                if (invid) {
                    console.log(invid.id);
                    doViewDetail(invid.id);
                }
            },
        });
      

display combo in edatagrid :
Code:
<th data-options="field:'supplier_id',width:50,  
formatter:function(value, row){
if (row.id == value) return row.suppl_name;
    },
    editor:{
type:'combobox',
        options:{ 
            url: 'index.php?r=supplier/getData',
            method:'get',
            valueField:'id',
            textField:'suppl_name',
            panelHeight:'auto'

    }">supplier</th>


data in combobox not display when grid loaded, but when i click/edited the combobox data work.

Can anyone help?
Thanks a lot in advance.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: September 25, 2013, 06:39:09 PM »

Please refer to this example http://jsfiddle.net/dGd5E/.
Logged
finzaiko
Newbie
*
Posts: 44


View Profile
« Reply #2 on: September 25, 2013, 10:57:17 PM »

Thanks stworthy, I try your snippet code worked for me and I found another way load json into variable
Code:
function getJson(url) {
        return JSON.parse($.ajax({
         type: 'GET',
         url: url,
         dataType: 'json',
         global: false,
         async:false,
         success: function(data) {
             return data;
         }
     }).responseText);
    }

var suppliers = getJson('index.php?r=supplier/getData');

 var peditor2 = {
        type: 'combobox',
        options: {
            valueField: 'id',
            textField: 'suppl_name',
            data: products,
            required: true
        }
    };

column display :
Code:
<th data-options="field:'supplier_id',width:50,  
                                formatter:function(value, row){
                                    for(var i=0; i<products.length; i++){
                                        if (products[i].id == value) return products[i].suppl_name;
                                    }
                                },
                                editor:peditor2">supplier</th>

Thanks for great support
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!