Search
8344 results 291-300
Forum
- 21st Jul 2011How To: Returning more/custom data from server side script and displayingSometimes you want more than the basic data from the server side. In this example, I want to show my users how many of the items in the table have been "completed" and how many remain "incomplete". There is a boolean field in my database named bComplete for that value. [code] // server side php /* Data set length of Complete items after filtering */ $sWhere ? $sWhere .= " and bComplete=1 " : $sWhere = " WHERE bComplete=1 "; $sQuery = " SELECT COUNT(".$sIndexColumn.") FROM $sTable $sWhere "; $rResultFilterTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error()); $aResultFilterTotal = mysql_fetch_array($rResultFilterTotal); $iCompleteTotal = intval($aResultFilterTotal[0]); [/code] and add this value (and the inverse of it) to the JSON return object [code] /* * Output */ $output = array( "sEcho" => $sEcho, "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "sQuery" => $sReturnQuery, "iCompleteTotal" => $iCompleteTotal, "iIncompleteTotal" => ($iFilteredTotal - $iCompleteTotal), "aaData" => array() ); [/code] On the client side, you can get these values from fnServerData, within the .getJSON() call. I will display the results in the sInfoPostFix [code] // ... "fnServerData": function ( sSource, aoData, fnCallback ) { $.getJSON( sSource, aoData, function (json) { /* Do whatever additional processing you want on the callback, then tell DataTables */ iComp = json.iCompleteTotal; iIncomp = json.iIncompleteTotal; spacer = ' '; oTable.fnSettings().oLanguage.sInfoPostFix = spacer + '['+iComp+' complete, '+iIncomp+' incomplete]'; fnCallback(json) }) }, // ... [/code]
- 7th Dec 2010Modifying aoColumns using client side scriptFirst of all, Data Tables is amazing. Specially for someone like me who knows bare minimum javascript. From what I understand datatables does not allow columns to be defined dynamically. I'm desperately looking for a work around. I cannot hide and show columns dynamically. That wont serve my purpose. I believe that I can achieve define column headers dynamically, on client side, by setting the oSettings.aoColumns property. Correct? If so, please help me understand what I'm doing wrong here; [code] var dataTableHeaders={"summary":[ { "sName":"Search Summary","bSortable":false,"bSearchable":false}, { "sName":"","bSortable":false,"bSearchable":false}, ], }; "fnServerData":function (sSource,aoData,fnCallback){ prev_url=getTableUri(); //Gets URI dynamically. This part is working fine var oSettings=$('#dTable1').dataTable().fnSettings(); oSettings.aoColumns=[]; for(i=0;i<dataTableHeaders.summary.length;i++) oSettings.aoColumns[i]=dataTableHeaders.summary[i] $.getJSON(prev_url,aoData,function(json){fnCallback(json)}); }, [/code] I really hope its not a complete rookie mistake.. :)
- 18th Nov 2010Java variable in php scriptHi there, Does anybody know if something like this can be done?? I'd like to select a mysql column with the 'aData' variable : [code] function fnFormatDetails ( oTable, nTr ) { var aData = oTable.fnGetData( nTr ); var sOut = ' '; sOut += ''+aData[1]+' '+aData[4]+''; sOut += 'Link to source:Could provide a link here'; sOut += 'Extra info:And any further details here (images etc)'; sOut += ' '; [/code]
- 27th Jul 2010Merging language file into the script fileI am now using a localization file with DataTables. Is it possible to merge the language file into the jquery.dataTables.min.js, so that the client side only need to request one file instead of two?
- 12th Nov 2025rowReorder has started adding extra rowsit was a global script I added to enable
- 5th Nov 2025Loading and Saving Sates to / from a Mariadb SQL database Take 2Filename: table.state_info.php /* * Editor server script for DB table statesave
- 28th Oct 2025way to batch importing to stay under the max_input_varsno. However, the edit.php script in this example (which
- 8th Oct 2025Need help, developed myself into a corner with no time . Allowed memory error on PHPinstanceDateTime, $_SERVER['PHP_SELF']); } /* * Editor server script for DB table Residents
- 10th Oct 2025Loading and Saving Sates to / from a Mariadb SQL databaseFilename: table.state_info.php /* * Editor server script for DB table statesave
- 29th Sep 2025Unable to set target 1 for columnControlupdate. With reordering the script references in the live