Please note that customization questions like this one are not covered in the included support for the plugin. Included support covers help with bugs and general inquiries for the plugin features, but not writing custom code. As you're developing some custom solution if you need our assistance we can offer you our paid customization service.
Generally it is so, but here I am using hook/s that you provided, which should do the job. There is existing function in your class which I also can use (addRows). But the fact that it checks for instance of "WDTRow" (class I presume), which does not exist anywhere in the code, makes me think that this may be a bug. If this is a bug, I'll expect a fix, and if its not a bug and I am wrong, than your previous message is relevant.
As you already said the filter returns datatable object but what are you trying to achieve it does not work like that. You find some lines that are from previous versions of plugin and they are needed to be changed, and I will give you my suggestion.
In file ../wp-content/plugins/wpdatatables/source/class.wpdatatable.php around line 822 find this code
if( !( $row instanceof WDTRow ) ) {
throw new WDTException( 'Please provide a proper wpDataTables Row' );
}
and comment it.
Than find this code around line 825
if( $row->countCells() != $this->countColumns() ) {
throw new WDTException( 'Count of the columns in table and in row is not equal. Row: '.$row->countCells().', table: '.$this->countColumns() );
}
and change it to be like this:
if( count($row) != $this->countColumns() ) {
throw new WDTException( 'Count of the columns in table and in row is not equal. Row: '.$row->countCells().', table: '.$this->countColumns() );
}
You will need to write your own method because we are developing functionalities and that methods are not finished yet and it is not easy as it looks to implement it so I hope this will help.
Ok, only now I got around to deal with this. Editing the class was my last option as I wanted to avoid touching your code to be able to update the plugin later automatically. Anyway since there is no other option for this, I have altered 2 functions, and it works fine now. You might want to add those insted of existing ones in future updates.
public function addWDTRow( $row ) {
if( count( $this->_wdtIndexedColumns ) == 0 ) {
throw new WDTException('Please add columns to wpDataTable first.');
}
if( count($row) != $this->countColumns() ) {
throw new WDTException( 'Count of the columns in table and in row is not equal. Row: '.count($row).', table: '.$this->countColumns() );
}
apply_filters( 'wdt_add_row', $row );
$this->_dataRows[] = &$row;
}
public function addRows( &$rows ) {
if( !is_array( $rows ) ) {
throw new WDTException('Please provide an array of WDTRow objects.');
}
apply_filters( 'wdt_add_dataRows', $rows );
foreach( $rows as &$row ) {
$this->addWDTRow( $row );
}
}
You should however pay attention here:
if( count($row) != $this->countColumns() ) {
This test might not be enough, since it does not test if array keys (column names) are right. If it was me, I'd do a function for addRows which only receives values and combines them with the right column names.
Thank you for your sharing your ideas and solution with us. We really appreciate it. I will forward this to our lead developer and maybe we will add this for our future releases. Thank you again.
I am trying to add row to wpdatatable object just before it renders. Here is what I got:
And I get "Please provide a proper wpDataTables Row" from function addWDTRow. It checks for instanceof WDTRow, but I cannot find such class.
How do I add row?
Thanks
Hi Dima,
Thank you for your purchase.
Please note that customization questions like this one are not covered in the included support for the plugin. Included support covers help with bugs and general inquiries for the plugin features, but not writing custom code. As you're developing some custom solution if you need our assistance we can offer you our paid customization service.
Thank you for understanding.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Generally it is so, but here I am using hook/s that you provided, which should do the job. There is existing function in your class which I also can use (addRows). But the fact that it checks for instance of "WDTRow" (class I presume), which does not exist anywhere in the code, makes me think that this may be a bug. If this is a bug, I'll expect a fix, and if its not a bug and I am wrong, than your previous message is relevant.
Hi Dima,
As you already said the filter returns datatable object but what are you trying to achieve it does not work like that.
You find some lines that are from previous versions of plugin and they are needed to be changed, and I will give you my suggestion.
In file ../wp-content/plugins/wpdatatables/source/class.wpdatatable.php around line 822 find this code
and comment it.
Than find this code around line 825
and change it to be like this:
You will need to write your own method because we are developing functionalities and that methods are not finished yet and it is not easy as it looks to implement it so I hope this will help.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Ok, only now I got around to deal with this. Editing the class was my last option as I wanted to avoid touching your code to be able to update the plugin later automatically. Anyway since there is no other option for this, I have altered 2 functions, and it works fine now. You might want to add those insted of existing ones in future updates.
You should however pay attention here:
This test might not be enough, since it does not test if array keys (column names) are right. If it was me, I'd do a function for addRows which only receives values and combines them with the right column names.
Anyway hope this will help you a bit.
Thanks
Hi Dima,
Thank you for your sharing your ideas and solution with us.
We really appreciate it.
I will forward this to our lead developer and maybe we will add this for our future releases.
Thank you again.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables