EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jmansur on September 08, 2015, 11:00:00 AM



Title: how to get the value of other columns in a combogrid ?
Post by: jmansur on September 08, 2015, 11:00:00 AM
I have this combogrid:

      $('#cbgridSucursal').combogrid({
         panelWidth: 500,
         panelHeight:250,
         required:true,
         singleSelect:true,
         missingMessage: 'Debe seleccionar una Sucursal.',
         idField: 'Codigo',
         textField: 'DescSuc',
         url: 'Ajax/get_Sucursales.asp?Nom=N',
         method: 'post',
         columns: [[
            {field:'Codigo',title:'Numero',width:40, align:'right'},
            {field:'DescSuc',title:'Nombre',width:120},
            {field:'SucServCodigo',title:'SucServCodigo',width:120},
            {field:'SucServDesc',title:'Servicio',width:150}
         ]],
         fitColumns: true,
         onSelect: function(rec){
            var g = $('#cbgridSucursal').combogrid('grid');   // get datagrid object
            var r = g.datagrid('getSelected');   // get the selected row

            selecting any combogrid row , always SucServCodigo is the first row of the combogrid

            alert('Ajax/get_Sucursales.asp?SucCod='+r.Codigo+'&SucServCod='+r.SucServCodigo);
            
                                Can I get the value of other columns in a combogrid ?
            $.ajax({
               type: 'GET',
               url: 'Ajax/get_Sucursales.asp?SucCod='+r.Codigo+'&SucServCod='+r.SucServCodigo,
               contentType :'charset=ISO-8859-1',
               success: function (result,textStatus, jqXHR) {
                  var DatSucInc = eval(result);
               },
               error: function (req, status, error) {
                  alert("ATENCION: Se produjo un error al buscar los datos de la Sucursal.");
               }
            });
         }
      });
      var grid = $('#cbgridSucursal').combogrid('grid');
      grid.datagrid('enableFilter');


Title: Re: how to get the value of other columns in a combogrid ?
Post by: stworthy on September 08, 2015, 05:42:43 PM
The 'onSelect' event has give you the selected row data, please try this:
Code:
$('#cbgridSucursal').combogrid({
onSelect: function(index,row){
var codigo = row.Codigo;
console.log(codigo);
//...
}
});


Title: Re: how to get the value of other columns in a combogrid ?
Post by: jmansur on September 10, 2015, 05:48:27 AM
My problem is that I had several rows with the same ID . In my combogrid , the unique key was two columns.
Solution : Create a new hidden column as key with two values

Best regardsssss


Title: Re: how to get the value of other columns in a combogrid ?
Post by: stworthy on September 10, 2015, 08:05:59 AM
The id field value must be unique. You have set 'idField' to 'Codigo', you can not load data with duplicate 'Codigo' field values.


Title: Re: how to get the value of other columns in a combogrid ?
Post by: jmansur on September 10, 2015, 08:08:01 AM
thankssssssssss