EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: finzaiko on March 31, 2016, 08:37:12 PM



Title: [SOLVED] GetRows specific column
Post by: finzaiko on March 31, 2016, 08:37:12 PM
Hi,
I still couldn't find the solution to get selected column like below :
var rows = $('#dgProformaInv').datagrid('getRows');
this rows return all datagrid content (all column of object as (id, name, address)
but I just want specified column (name,address)

Thanks any help.


Title: Re: GetRows specific column
Post by: devnull on March 31, 2016, 10:00:35 PM
I have not tested this, but how about:

Code:
  var rows = $('#dgProformaInv').datagrid('getRows').filter(row){
    return {name:row.name,address:row.address};
  })


Title: Re: GetRows specific column
Post by: finzaiko on March 31, 2016, 11:14:39 PM
Still got an error, what is correct syntax using filter(row) ?


Title: Re: GetRows specific column
Post by: devnull on April 01, 2016, 12:04:12 AM
Sorry, it appears that filter -> return returns the whole row, use map() instead:

Code:
    var rows = []; dg.datagrid('getRows').map(function(row){
     rows.push({name:row.name,address:row.address});
    })

I hijacked someone else's fiddle: http://jsfiddle.net/FFTQr/8/


Title: Re: GetRows specific column
Post by: finzaiko on April 01, 2016, 12:14:20 AM
Thanks a lot devnull, Its work :)