EasyUI Forum
May 21, 2024, 01:57:50 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: how to get the value of other columns in a combogrid ?  (Read 9987 times)
jmansur
Newbie
*
Posts: 31


View Profile
« 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');
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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);
//...
}
});
Logged
jmansur
Newbie
*
Posts: 31


View Profile
« Reply #2 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
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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.
Logged
jmansur
Newbie
*
Posts: 31


View Profile
« Reply #4 on: September 10, 2015, 08:08:01 AM »

thankssssssssss
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!