server side use, nothing append on filter/search/order/next-prev, etc...
server side use, nothing append on filter/search/order/next-prev, etc...
madmike
Posts: 30Questions: 4Answers: 0
Hi,
I have a problem on server side use. The data are well loaded on content's display, but after, when i'm using input filters, search, etc... It's like ther is no server side call again. On firebug, I can't see XHR, is just call @ load only, nothing more on any action like next / prev or search.
I certainly have a mistake in the jquery call, but can't find where.
This is my code (warning php inside too):
[code]
var oTable = $('.dynamicTable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "stdout_json.php?r=<?php echo($table_name); ?>",
"sPaginationType": "full_numbers",
"bJQueryUI": false,
"bAutoWidth": false,
"bLengthChange": false,
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
"oLanguage": {
"sSearch": "Search all columns:",
"sLengthMenu": "_MENU_ records"
},
"bSortClasses": false,
"sDom": "<'row-fluid'<'span6'Tl><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
<?php echo $_SESSION["aoColumnDefs"]."\r\n"; ?>
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
"bLengthChange": true,
"bInfo": true,
"bStateSave": true,
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf",
"sRowSelect": "single",
"aButtons": [
{
"sExtends": "select",
"sButtonText": "Edit selected",
"bSelectedOnly": "true",
"mColumns": [0]
},
{
"sExtends": "text",
"sButtonText": \'Create\',
"sToolTip": "Create a new product",
},
{
"sExtends": "text",
"sButtonText": \'Delete\',
"sToolTip": "Delete product",
},
{
"sExtends": "collection",
"sButtonText": 'Export ',
"aButtons": [
"print",
{
"sExtends": "csv",
"sButtonText": "CSV all columns",
"sToolTip": "Save displayed table and all columns as CSV",
"bShowAll": true,
"mColumns": "all"
},
{
"sExtends": "csv",
"sButtonText": "CSV visible columns",
"sToolTip": "Save displayed table and visible columns as CSV",
"mColumns": "visible"
},
{
"sExtends": "pdf",
"sButtonText": "PDF All columns",
"mColumns": "all",
"sPdfOrientation": "landscape",
"sPdfMessage": "<?php echo date('l jS \of F Y h:i:s A'); ?>"
},
{
"sExtends": "pdf",
"sButtonText": "PDF Visible columns",
"mColumns": "visible",
"sPdfOrientation": "landscape",
"sPdfMessage": "<?php echo date('l jS \of F Y h:i:s A'); ?>"
}
]
}
]
},
"fnInitComplete": function() {
var oSettings = $('.dynamicTable').dataTable().fnSettings();
for ( var i=0 ; i0){
$(".dynamicTable tfoot input")[i].value = oSettings.aoPreSearchCols[i].sSearch;
$(".dynamicTable tfoot input")[i].className = "";
}
}
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
var id = aData[0];
$(nRow).attr("id",id);
return nRow;
},
"fnDrawCallback": function () {
/* Apply the jEditable handlers to the table */
/* ... removed dur to loooong message .....*/
}
});
$(".dynamicTable tfoot th input").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, $("tfoot input").index(this) );
} );
$(".dynamicTable tfoot th input").each( function (i) {
asInitVals[i] = this.value;
} );
$(".dynamicTable tfoot th input").focus( function () {
if ( this.className == "search_init" )
{
this.className = "";
this.value = "";
}
} );
$(".dynamicTable tfoot th input").blur( function (i) {
if ( this.value == "" )
{
this.className = "search_init";
this.value = asInitVals[$("tfoot input").index(this)];
}
} );
$('.dynamicTable td').live('click',function(){
var aPos = pTable.fnGetPosition(this);
var aData = pTable.fnGetData(aPos[0]);
alert(aData);
});
$.extend( $.fn.dataTableExt.oStdClasses, {
"sWrapper": "dataTables_wrapper form-inline"
} );
[/code]
I have a problem on server side use. The data are well loaded on content's display, but after, when i'm using input filters, search, etc... It's like ther is no server side call again. On firebug, I can't see XHR, is just call @ load only, nothing more on any action like next / prev or search.
I certainly have a mistake in the jquery call, but can't find where.
This is my code (warning php inside too):
[code]
var oTable = $('.dynamicTable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "stdout_json.php?r=<?php echo($table_name); ?>",
"sPaginationType": "full_numbers",
"bJQueryUI": false,
"bAutoWidth": false,
"bLengthChange": false,
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
"oLanguage": {
"sSearch": "Search all columns:",
"sLengthMenu": "_MENU_ records"
},
"bSortClasses": false,
"sDom": "<'row-fluid'<'span6'Tl><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
<?php echo $_SESSION["aoColumnDefs"]."\r\n"; ?>
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
"bLengthChange": true,
"bInfo": true,
"bStateSave": true,
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf",
"sRowSelect": "single",
"aButtons": [
{
"sExtends": "select",
"sButtonText": "Edit selected",
"bSelectedOnly": "true",
"mColumns": [0]
},
{
"sExtends": "text",
"sButtonText": \'Create\',
"sToolTip": "Create a new product",
},
{
"sExtends": "text",
"sButtonText": \'Delete\',
"sToolTip": "Delete product",
},
{
"sExtends": "collection",
"sButtonText": 'Export ',
"aButtons": [
"print",
{
"sExtends": "csv",
"sButtonText": "CSV all columns",
"sToolTip": "Save displayed table and all columns as CSV",
"bShowAll": true,
"mColumns": "all"
},
{
"sExtends": "csv",
"sButtonText": "CSV visible columns",
"sToolTip": "Save displayed table and visible columns as CSV",
"mColumns": "visible"
},
{
"sExtends": "pdf",
"sButtonText": "PDF All columns",
"mColumns": "all",
"sPdfOrientation": "landscape",
"sPdfMessage": "<?php echo date('l jS \of F Y h:i:s A'); ?>"
},
{
"sExtends": "pdf",
"sButtonText": "PDF Visible columns",
"mColumns": "visible",
"sPdfOrientation": "landscape",
"sPdfMessage": "<?php echo date('l jS \of F Y h:i:s A'); ?>"
}
]
}
]
},
"fnInitComplete": function() {
var oSettings = $('.dynamicTable').dataTable().fnSettings();
for ( var i=0 ; i0){
$(".dynamicTable tfoot input")[i].value = oSettings.aoPreSearchCols[i].sSearch;
$(".dynamicTable tfoot input")[i].className = "";
}
}
},
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
var id = aData[0];
$(nRow).attr("id",id);
return nRow;
},
"fnDrawCallback": function () {
/* Apply the jEditable handlers to the table */
/* ... removed dur to loooong message .....*/
}
});
$(".dynamicTable tfoot th input").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, $("tfoot input").index(this) );
} );
$(".dynamicTable tfoot th input").each( function (i) {
asInitVals[i] = this.value;
} );
$(".dynamicTable tfoot th input").focus( function () {
if ( this.className == "search_init" )
{
this.className = "";
this.value = "";
}
} );
$(".dynamicTable tfoot th input").blur( function (i) {
if ( this.value == "" )
{
this.className = "search_init";
this.value = asInitVals[$("tfoot input").index(this)];
}
} );
$('.dynamicTable td').live('click',function(){
var aPos = pTable.fnGetPosition(this);
var aData = pTable.fnGetData(aPos[0]);
alert(aData);
});
$.extend( $.fn.dataTableExt.oStdClasses, {
"sWrapper": "dataTables_wrapper form-inline"
} );
[/code]
This discussion has been closed.
Replies
Allan
If you don't want to make the page public, you can PM me by clicking here: http://datatables.net/forums/messages/add/allan .
Regards,
Allan
> TypeError: 'undefined' is not an object (evaluating '$.editable.types[settings.type].plugin')
The types you have available are: `charcounter` , `select` , `text` and `textarea` (in $.editable.types) so I guess you are trying to use a type which isn't available in jEditable? I should note that jEditable isn't part of DataTables, so I might only be able to offer limited support for it, as I'm not completely familiar with its code base.
Also, when I try to load your page in Chrome, nothing works since the page you linked me to is https, but it is trying to load control from http:// which Chrome is blocking as insecure.
Regards,
Allan
About the http call, is it an ajax setting to force http call ?
Thanks
Nothing to do with Ajax the Chrome issue I was seeing. You page is being served up from https:// (at least the link you give me is), but you are included unsecured content:
[code]
[/code]
Chrome doesn't like that is is blocking the script since it is not on a secured connection, while the host page is.
You can solve this by using:
[code]
[/code]
The `//` tells the browser to load using the host page's protocol.
There are a few other includes that are on the page which will also need this treatment. If you look at the console pane in Chrome's developer tools you'll see the warnings about the blocked content.
Regards,
Allan
I'm searching more about the "editable" issue. I don't found where set the types.
Where do you initialise jEditable? The type should be defined in there.
> About the buttons, There is an example using selected row + select button for opening an ajax fill dialog ?
There isn't, but you would just bind an Ajax event to happen on the click:
[code]
$('tbody td img').click( function () {
var data = table.fnGetData( $(this).parents('tr')[0] );
$.ajax( {
url: '/getData?id='+data[0],
dataType: 'json',
success: function ( json ) {
// Show dialogue based on JSON
}
} );
[/code]
Obviously there are some gaps you'd need to fill in there (for example are you using an image?), actually calling the dialogue to show (depends what dialogue library you are using), formatting the data (depends on the data) etc, but that's the basic idea.
Regards,
Allan
What do you think about something like this ?
[code]
{
"sExtends": "text",
"sButtonText": \'Upload CSV\',
"sToolTip": "Click to upload a CSV file",
}
[/code]
I'll keep you in touch.
[code]
{
"sExtends": "text",
"sButtonText": 'Upload CSV',
"sToolTip": "Click to upload a CSV file",
"fnClick": function ( button, config ) {
$('#myModal').modal('show')
}
}
[/code]
I think that will serve you better.
Regards,
Allan
Allan
[code]
[/code]
for example. This is much easier, as it means that you don't need to manipulate the value using Javascript - the browser does it all for you. It is also well supported by all current browser releases: http://caniuse.com/#search=placeholder
Allan
[code][/code]
If i remove the "text" and just use a "search_init" it's ok, but I don"t see wich script add the "text" in the class. By default I only build the html with the "search_init" class only.
[quote]allan said: [code] {
"sExtends": "text",
"sButtonText": 'Upload CSV',
"sToolTip": "Click to upload a CSV file",
"fnClick": function ( button, config ) {
$('#myModal').modal('show')
}
}[/code][/quote]
Use the `remote` option: http://twitter.github.com/bootstrap/javascript.html#modals .
[code]
$('#myModal').modal({
remote: {url}
});
[/code]
> If i remove the "text" and just use a "search_init" it's ok, but I don"t see wich script add the "text" in the class.
Nothing that I see in the Javascript on the page. Possibly one of the libraries. However the 'fix' is relatively simple - change
> if ( this.className == "search_init" )
to
[code]
if ( $(this).hasClass( 'search_init' ) )
[/code]
and
> this.className = "search_init";
to
[code]
$(this).addClass( "search_init" );
[/code]
Allan
The problem is that one of the columns is hidden ( `"bVisible": false` ) which knocked the `index()` method out of 'alignment' - i.e. the index() method is calculating the visible index, but DataTables expects the column index.
This can be resolved by using the fnVisibleToColumnIndex plug-in ( http://datatables.net/plug-ins/api#fnVisibleToColumnIndex ). Simply include the code for that plug-in in your page (after you include the DataTables file, but before you initialise the DataTable) and change:
> oTable.fnFilter( this.value, $("tfoot input").index(this) );
to
[code]
oTable.fnFilter( this.value, oTable.fnVisibleToColumnIndex( $("tfoot input").index(this) ) );
[/code]
and
> this.value = asInitVals[$("tfoot input").index(this)];
to
[code]
this.value = asInitVals[ oTable.fnVisibleToColumnIndex( $("tfoot input").index(this) ) ];
[/code]
And that should do it. It should also make the filtering work correct, since it if off set by one at the moment!
Regards,
Allan
So many, many, many, thanks for you amazing tool and your so useful help. It work perfect now !
Thanks a lot, for all your patience and shared knowledge.
Mike