You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by russellJB <se...@optonline.net> on 2012/04/03 18:39:30 UTC

Calling fnStandingRedraw to retain the current pagination settings using javaScriptSupport.addInitializerCall

Hello All!

I am using the CreateEventLink method of the ComponentResources class to
create a link to a delete event on my page called UserList using the
following:

"resources.createEventLink("delete", user.getUserId()).toURI();"

The UserList page uses datatables to create a list of user's data and a
delete link. When the delete link is clicked,  the delete event is called on
the same page and everyone is happy.


The problem is the datatable goes back to the first page of records after a
user is deleted. For example, if I am on page 5 of my datatable, on the
UserList page, and I click delete it will stay on the Userlist page, but my
datatable will reset itself to the first page. 


After some research I haved discovered that the fnStandingRedraw plugin from
datatables will fix this issue: http://datatables.net/plug-ins/api


Going through the documentation I have learned that I should use:

 javaScriptSupport.addInitializerCall("fnStandingRedraw", "");

to call the following in js file via an Import notation:


Tapestry.Initializer.fnStandingRedraw = function(oSettings) {
    //redraw to account for filtering and sorting
    // concept here is that (for client side) there is a row got inserted at
the end (for an add)
    // or when a record was modified it could be in the middle of the table
    // that is probably not supposed to be there - due to filtering /
sorting
    // so we need to re process filtering and sorting
    // BUT - if it is server side - then this should be handled by the
server - so skip this step
    if(oSettings.oFeatures.bServerSide === false){
        var before = oSettings._iDisplayStart;
        oSettings.oApi._fnReDraw(oSettings);
        //iDisplayStart has been reset to zero - so lets change it back
        oSettings._iDisplayStart = before;
        oSettings.oApi._fnCalculateEnd(oSettings);
    }

    //draw the 'current' page
    oSettings.oApi._fnDraw(oSettings);
};


However I get the error:

Uncaught TypeError: Cannot read property 'bServerSide' of undefined
Tapestry.Initializer.fnStandingRedrawhelpdesk.js:16
$.extend.inittapestry-jquery.js:32
jQuery.extend.eachjquery-1.6.2.js:655
$.extend.inittapestry-jquery.js:26
jQuery.extend.eachjquery-1.6.2.js:649
$.extend.inittapestry-jquery.js:18
(anonymous function)list:70
jQuery.extend._Deferred.deferred.resolveWithjquery-1.6.2.js:1008
jQuery.extend.readyjquery-1.6.2.js:436
DOMContentLoadedjquery-1.6.2.js:915



Any guidance would be most appreciated...Thanks in advance!!


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Calling-fnStandingRedraw-to-retain-the-current-pagination-settings-using-javaScriptSupport-addInitial-tp5615771p5615771.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Calling fnStandingRedraw to retain the current pagination settings using javaScriptSupport.addInitializerCall

Posted by russellJB <se...@optonline.net>.
Thanks Paul! I was beginning to feel like the step child here!

I was able to work around the issue by setting the "bStateSave" parameter to
"true" in my JSONObject controlling my dataTable Options... This causes a
cookie to save the state of my datatable after any updates
(http://www.datatables.net/ref#bStateSave) 

However, my original plan of attack is still not working and I know this
issue is going to come up again.

I believe you are right that I am using .addInitializerCall unnecessarily. I
was able to make a call using 
javaScriptSupport.addScript("fnStandingRedraw();"); just like you suggested
however now I think the problem is in how I am setting up my javascript
file. 


Here is the JavaScript that I placed in a separate file:

$.fn.dataTableExt.oApi.fnStandingRedraw = function(oSettings) {
    //redraw to account for filtering and sorting
    // concept here is that (for client side) there is a row got inserted at
the end (for an add) 
    // or when a record was modified it could be in the middle of the table
    // that is probably not supposed to be there - due to filtering /
sorting
    // so we need to re process filtering and sorting
    // BUT - if it is server side - then this should be handled by the
server - so skip this step
    if(oSettings.oFeatures.bServerSide === false){
        var before = oSettings._iDisplayStart;
        oSettings.oApi._fnReDraw(oSettings);
        //iDisplayStart has been reset to zero - so lets change it back
        oSettings._iDisplayStart = before;
        oSettings.oApi._fnCalculateEnd(oSettings);
    }
     
    //draw the 'current' page
    oSettings.oApi._fnDraw(oSettings);
};


Not really a js guy (yet) so I'm wondering if there is some sort of Tapestry
namespace that I should be to or something else i'm not seeing

Thanks!



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Calling-fnStandingRedraw-to-retain-the-current-pagination-settings-using-javaScriptSupport-addInitial-tp5615771p5618718.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Calling fnStandingRedraw to retain the current pagination settings using javaScriptSupport.addInitializerCall

Posted by Paul Stanton <pa...@mapshed.com.au>.
Have you tried

javaScriptSupport.addScriptCall("fnStandingRedraw();");

instead? I'm not sure if fnStandingRedraw is in fact a simple javascript method or a valid initializer.

p.


On 4/04/2012 2:39 AM, russellJB wrote:
> Hello All!
>
> I am using the CreateEventLink method of the ComponentResources class to
> create a link to a delete event on my page called UserList using the
> following:
>
> "resources.createEventLink("delete", user.getUserId()).toURI();"
>
> The UserList page uses datatables to create a list of user's data and a
> delete link. When the delete link is clicked,  the delete event is called on
> the same page and everyone is happy.
>
>
> The problem is the datatable goes back to the first page of records after a
> user is deleted. For example, if I am on page 5 of my datatable, on the
> UserList page, and I click delete it will stay on the Userlist page, but my
> datatable will reset itself to the first page.
>
>
> After some research I haved discovered that the fnStandingRedraw plugin from
> datatables will fix this issue: http://datatables.net/plug-ins/api
>
>
> Going through the documentation I have learned that I should use:
>
>   javaScriptSupport.addInitializerCall("fnStandingRedraw", "");
>
> to call the following in js file via an Import notation:
>
>
> Tapestry.Initializer.fnStandingRedraw = function(oSettings) {
>      //redraw to account for filtering and sorting
>      // concept here is that (for client side) there is a row got inserted at
> the end (for an add)
>      // or when a record was modified it could be in the middle of the table
>      // that is probably not supposed to be there - due to filtering /
> sorting
>      // so we need to re process filtering and sorting
>      // BUT - if it is server side - then this should be handled by the
> server - so skip this step
>      if(oSettings.oFeatures.bServerSide === false){
>          var before = oSettings._iDisplayStart;
>          oSettings.oApi._fnReDraw(oSettings);
>          //iDisplayStart has been reset to zero - so lets change it back
>          oSettings._iDisplayStart = before;
>          oSettings.oApi._fnCalculateEnd(oSettings);
>      }
>
>      //draw the 'current' page
>      oSettings.oApi._fnDraw(oSettings);
> };
>
>
> However I get the error:
>
> Uncaught TypeError: Cannot read property 'bServerSide' of undefined
> Tapestry.Initializer.fnStandingRedrawhelpdesk.js:16
> $.extend.inittapestry-jquery.js:32
> jQuery.extend.eachjquery-1.6.2.js:655
> $.extend.inittapestry-jquery.js:26
> jQuery.extend.eachjquery-1.6.2.js:649
> $.extend.inittapestry-jquery.js:18
> (anonymous function)list:70
> jQuery.extend._Deferred.deferred.resolveWithjquery-1.6.2.js:1008
> jQuery.extend.readyjquery-1.6.2.js:436
> DOMContentLoadedjquery-1.6.2.js:915
>
>
>
> Any guidance would be most appreciated...Thanks in advance!!
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Calling-fnStandingRedraw-to-retain-the-current-pagination-settings-using-javaScriptSupport-addInitial-tp5615771p5615771.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org