Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flexigrid get selected row columns values

Tags:

flexigrid

I am new to flexigrid. can any one please let me know how to get the selected row each column values.?

How to i get each column name(reportName and reportDescription)? because i am push //all the data into array like mentioned below.

I am using below code to get the selected rows. But it is returning null. Can you please help me on the same?

//Column. <br/>


colModel: [
  { display: 'WidgetID', name: 'WidgetID', width: 50, sortable: true, align: 'left', hide: true },
  { display: 'Widget Name', name: 'WidgetName', width: 170, sortable: true, align: 'left' },
  { display: 'IsClientReport', name: 'IsClientReport', width: 50, sortable: false, align: 'left', hide: true },
  { display: 'ClientReportID', name: 'ClientReportID', width: 50, sortable: false, align: 'left', hide: true },
  { display: 'ReportType', name: 'ReportType', width: 280, sortable: true, align: 'left' }
],

$('#grid01').click(function(event){ 
  $('.trSelected', this).each( function(){ 
      console.log( ' rowId: ' + $(this).attr('id').substr(3) + ' IsClientReport: ' + $('td[abbr="IsClientReport"] >div', this).html() + ' sign: ' + $('td[abbr="WidgetID"] >div', this).html() + ' ReportType: ' + $('td[abbr="ReportType"] >div', this).html() ); 
  }); 
});

Thanks, Pon Kumar Pandian

like image 638
Pon Kumar Pandian Avatar asked Feb 19 '23 14:02

Pon Kumar Pandian


2 Answers

Not sure if you've already figured it out, but I'm going to leave this answer here in case anyone else in the same situation stumbles across your question like I did.

Setting 'sortable: false' on a column removes the 'abbr' attribute from the 'td' that is generated by Flexigrid. This means you can't use the recommended solution for getting the selected row.

I modified the flexigrid.js file myself to fix this issue.

Flexigrid previously only added the 'abbr' attribute if a column had a 'name' and had 'sortable: true'. I removed the condition of 'sortable: true'.

This, in turn, also meant that the columns would always be sortable. To prevent this, I added a 'sortable' attribute, which would only be set if the column is 'sortable: true'

After that, I had to go through and find all situations where 'abbr' was being used as a condition for sorting, and replaced it with a check for 'sortable'.

That's it.

I uploaded the file to mediafire if you just want to be able to download and use this one instead. There's a few too many changes in non-specific places for me to show my changes in code here. If need be, I can provide diffs or more of an explanation. Note that 'sortable: true' still works with my fix.

like image 125
Maleckai Avatar answered Feb 27 '23 23:02

Maleckai


I had the same issue, and solved it by using the following code

 jQuery('#schoolist .trSelected').each( function(){
                alert(jQuery('[abbr="name"]',this).text());

            });

Just add it to the function and replace the id #schoolist and abbr name with the name of the column you need.

like image 20
themhz Avatar answered Feb 27 '23 21:02

themhz