[Solved] Static Number Column with Ajax Source.
[Solved] Static Number Column with Ajax Source.
Hey guys,
I'm rather new to datatables (amazing plugin by the way, I've never seen such well documented code for open source before...).
I'm currently trying to add a static index number as the first column in my table. However the way we have Django set up it is creating our Json array with database IDs which is fine however when I try to add a blank column with :
[code] "aoColumns": [
{ "mDataProp": null },
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
],[/code]
We get an error: "DataTables warning (table id = 'lookup_results'): Requested unknown parameter '10' from the data source for row 0" as it appears to be writing over the first column anyways. And it works for the first 10 times loaded by over writing our ID column rather than using it's own. But as soon as you change the number of results shown it doesn't continue to count, it just uses the actual ID rather than adding the row numbers.
Our views.py creating the Json array looks like:
[code]results = Person.objects.filter(**query).values_list(
'id', 'first_name', 'last_name', 'address__street_number',
'address__street_name', 'address__city',
'address__postal_code', 'phone_number', 'gender', 'pol_id')[/code]
As per the example I'm adding the static column using this:
[code] "fnDrawCallback": function ( oSettings ) {
/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
for ( var i=0, iLen=oSettings.aiDisplay.length ; i
I'm rather new to datatables (amazing plugin by the way, I've never seen such well documented code for open source before...).
I'm currently trying to add a static index number as the first column in my table. However the way we have Django set up it is creating our Json array with database IDs which is fine however when I try to add a blank column with :
[code] "aoColumns": [
{ "mDataProp": null },
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
],[/code]
We get an error: "DataTables warning (table id = 'lookup_results'): Requested unknown parameter '10' from the data source for row 0" as it appears to be writing over the first column anyways. And it works for the first 10 times loaded by over writing our ID column rather than using it's own. But as soon as you change the number of results shown it doesn't continue to count, it just uses the actual ID rather than adding the row numbers.
Our views.py creating the Json array looks like:
[code]results = Person.objects.filter(**query).values_list(
'id', 'first_name', 'last_name', 'address__street_number',
'address__street_name', 'address__city',
'address__postal_code', 'phone_number', 'gender', 'pol_id')[/code]
As per the example I'm adding the static column using this:
[code] "fnDrawCallback": function ( oSettings ) {
/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
for ( var i=0, iLen=oSettings.aiDisplay.length ; i
This discussion has been closed.
Replies