Author Topic: getCellsByClass is not working, throwing javascript error  (Read 3672 times)

Sunny

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 59
    • View Profile
getCellsByClass is not working, throwing javascript error
« on: August 05, 2015, 11:09:43 pm »
Hi,

I tried to use getCellsByClass method, but its throwing me below Javascript error:

TypeError: this.hasClass is not a function
pqgrid.min.js
Line 168


I tried in one of your demo:http://paramquery.com/pro/demos24/row_styles, added below line at the end to reproduce this issue:
console.log($("#grid_row_styles").pqGrid('getCellsByClass',{cls:'green'}));

Please advice.


Sunny

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 59
    • View Profile
Re: getCellsByClass is not working, throwing javascript error
« Reply #1 on: August 11, 2015, 11:49:49 pm »
Hi,

Is there any workaround for this defect ?

I have a requirement to freeze columns dynamically. When user clicks on header cell(column) and click on button(freeze) in the tool bar, grid has to freeze the columns up to the selected header cell. For this purpose, I am thinking to use the getCellsByClass to find the selected header cell and pass the corresponding colIndx to freeze the grid.

Appreciate if you can provide any advice.

Thanks.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6210
    • View Profile
Re: getCellsByClass is not working, throwing javascript error
« Reply #2 on: August 12, 2015, 06:00:56 pm »
you may use this patch for getCellsByClass

Code: [Select]
$.paramquery.pqGrid.prototype.getCellsByClass=function(a){var t=this,o=this.options,n=o.dataModel,r=o.pageModel,l=r.type,d="remote"==l?!0:!1,e=this.rowIndxOffset,w=n.data,s=this.colModel,x=s.length,I=[],i=function(a){for(var o=0;x>o;o++){var n=s[o],r=n.dataIndx;if(a.dataIndx=r,t.hasClass(a)){var l={rowData:a.rowData,dataIndx:r,colIndx:o,rowIndx:a.rowIndx};I.push(l)}}};if(null==w)return I;if(null!=a.rowIndx||null!=a.rowIndxPage||null!=a.rowData)a.rowData=a.rowData||this.getRowData(a),null==a.rowIndx&&(a.rowIndx=this.getRowIndx({rowData:u})),i(a);else for(var f=0,h=w.length;h>f;f++){var u=w[f];a.rowData=u,a.rowIndx=d?f+e:f,i(a)}return I};

http://jsfiddle.net/kw77c0sg/11/

However getCellsByClass only returns the cell to whom class is added by addClass or JSON notation rowData.pq_cellcls.


You may use selection API to get the selected cell and freeze columns to the left of selected cell similar to Excel.
http://paramquery.com/pro/api#method-selection
« Last Edit: August 12, 2015, 06:39:44 pm by paramquery »

Sunny

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 59
    • View Profile
Re: getCellsByClass is not working, throwing javascript error
« Reply #3 on: August 12, 2015, 09:16:51 pm »
Thank you for the patch. Selection API works great, thank you  :)