Author Topic: Hide detailModel if it's empty?  (Read 3951 times)

dbadmin

  • Pro Economy
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Hide detailModel if it's empty?
« on: October 09, 2014, 12:13:41 am »
Hi!

I was wondering, if there  is a way to hide a collapse image in the very left column (which controls showing of a detail model) if I know ahead of time that it's going to be empty? Let's say I'll have a column in the main grid that will tell me that.

Thanks!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Hide detailModel if it's empty?
« Reply #1 on: October 09, 2014, 08:02:51 pm »
you could do it in refresh event by iterating over all rows in dataModel.data,

in refresh event

do a for loop on dataModel.data

if(rowData['field'] == false ){ //where field is dataIndx of field where you want to store prior info about detail of a row.
  get $td from call to getCell ({ rowIndx: i, dataIndx: 'pq_detail' }); 
  $td.empty();
}
« Last Edit: October 09, 2014, 08:46:48 pm by paramquery »

dbadmin

  • Pro Economy
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Hide detailModel if it's empty?
« Reply #2 on: January 23, 2015, 08:12:02 pm »
Hi!

So I tried that, but it gets rid of the cell borders and looks weird, instead I did the following:

var $td = $("#grid_array").pqGrid( "getCell", { rowIndx: i, dataIndx: "pq_detail" } ); 
                    $td.html(' ');

Now the problem is, when I click on this empty cell it still opens up detail grid.
How do I avoid that?

Thanks!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Hide detailModel if it's empty?
« Reply #3 on: February 17, 2015, 11:02:23 pm »
1) The rendering of icon in detail column can also be customized more conveniently with column.render callback.

column.render = function ( ui ){
  if( some condition ){
    //return custom html "" or " ";
  }
  else {
    return null; // let the default rendering take place.
  }
}


2) There is an event beforeRowExpand added in v2.4.0 which helps to prevent default action of expansion of row by returning false.
http://paramquery.com/pro/api#event-beforeRowExpand
« Last Edit: February 17, 2015, 11:03:55 pm by paramquery »

raviledwani

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Hide detailModel if it's empty?
« Reply #4 on: June 21, 2018, 10:03:51 pm »
Thank you!
You solution worked perfectly. I used "beforeRowExpand" in combination with "colModel.render".