corrisoft / jquery-datatables-row-grouping

Automatically exported from code.google.com/p/jquery-datatables-row-grouping
0 stars 0 forks source link

sGroup is undefined when mDataProp is ised as a data source #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. Use version 1.1.2 of row grouping with version 1.8.2 of datatables
2. Call rowGrouping() on oTable.

You'll see an error that says: 
sGroup is undefined - line 122

Not sure if this is because I'm passing the data in using aoColumns and aodata.

To fix you need to change line 286 from:
sGroupData = 
oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]]._aData[properties.iGrouping
ColumnIndex];

to:
sGroupData = 
oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]]._aData[oSettings.aoColumns[
properties.iGroupingColumnIndex].mDataProp];                    

Basically sGroupData gets undefined set to it (which carries through to line 
122) because _aData isn't an array or indexable... it's an object with the 
mDataProp values as keys.

Original issue reported on code.google.com by she...@gmail.com on 9 Nov 2011 at 9:48

GoogleCodeExporter commented 9 years ago
This also should be done for second level of grouoping.

Original comment by serbiaun...@gmail.com on 22 Dec 2011 at 12:44

GoogleCodeExporter commented 9 years ago
This code will not work for more complex mDataProp e.g. "mDataProp": 
"innerBean.name"

Original comment by serbiaun...@gmail.com on 22 Dec 2011 at 12:47

GoogleCodeExporter commented 9 years ago
My solution for more complex mDataProp (e.g. "mDataProp": "innerBean.name") is 
like this:
var tmp1 = oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]];
var tmp2 = oSettings.aoColumns[properties.iGroupingColumnIndex].mDataProp;
sGroupData = eval("tmp1._aData." + tmp2);

Original comment by serbiaun...@gmail.com on 27 Dec 2011 at 9:06

GoogleCodeExporter commented 9 years ago

Original comment by joc...@gmail.com on 11 Feb 2012 at 10:40

GoogleCodeExporter commented 9 years ago
Hi,

This is fixed in the latest version of plugin. Could you please take a look at 
the 
http://jquery-datatables-row-grouping.googlecode.com/svn/trunk/serverSideJSONP-o
bjects.html where I have used server side processing with object data source 
and it works now. Here is used JSONP call because server-side processing page 
is on Allans datatables site, and I do not have php hosting on google code. 

I have used solution similar to one that serbiaunite has proposed:

sGroupData = 
oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]]._aData[properties.iGrouping
ColumnIndex];
if (sGroupData == undefined)
       sGroupData = oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]]._aData[oSettings.aoColumns[properties.iGroupingColumnIndex].mDataProp ]; 

It seems to me that it works on the demo site. Let me know whether it works in 
your example.

serbaiunite hvala na pomoci, drago mi je da uspesno koristis ovaj plugin.

Jovan

Original comment by joc...@gmail.com on 11 Feb 2012 at 7:23

GoogleCodeExporter commented 9 years ago
Hi,

I tested this fix but it doesn't work in my case. It is the problem I
described in one of my comments on this bug. I have scenario where
sGroupData2 comes from complex source. My DT definition has this part:
"aoColumns" : [
   {....
   { "mDataProp": "innerBean.name" },
    ...
and this value I want to display in second level of grouping. So I used
this solution that also works in simple cases:
if (sGroupData2 == undefined){
   tmp1 = oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]];
   tmp2 = oSettings.aoColumns[properties.iGroupingColumnIndex2].mDataProp;
   sGroupData2 = eval("tmp1._aData." + tmp2);
}

Thanks for the useful plugin!

11. фебруар 2012. 20.24, <jquery-datatables-row-grouping@googlecode.com> 
је
написао/ла:

Original comment by serbiaun...@gmail.com on 13 Feb 2012 at 8:57

GoogleCodeExporter commented 9 years ago
I am sorry but none of these solutions work when mDataProp is a function. Any 
suggestions?

Thank you.

Original comment by sergey.n...@gmail.com on 23 Mar 2012 at 12:29