Passive dataTable

Passive dataTable

sansan Posts: 4Questions: 0Answers: 0
edited August 2012 in General
Hi, Allan! I didn't found an answer for my issue in forum. So don't blame me for my question too hard =).
I have an architectural approach that forces me to make my dataTable passive. I have a manager on a page - some kind of an observer+mediator. This manager gets a set of data from a server and distributes it to a collection of controls on a page. Among that collection is my dataTable. So my dataTable has to receive a ready array of data and treat with it like a fnCallback does in fnServerData:

[code]
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(response){
//do some work here
fnCallback(response);
}
} );
[/code]
As I see there is a way to use fnAddData. But it's quite not comfortable. And I have to update number of selected rows, total rows, update page number and so on.
I found a way to make it, but it's a hack. And I would like to avoid hacks =).
Is there any way to do it with standard tools?

Thanks, Alex.

Replies

  • sansan Posts: 4Questions: 0Answers: 0
    I've found another solution for this. To use _fnAjaxUpdateDraw( oSettings, json ) private method. I'ts not a good idea, but can't see another way.

    Thanks, All

    PS
    Good work Allan =)
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    I don't quite 100% understand I'm afraid - why don't you want to use fnClearTable and fnAddData? The API methods are there to be used :-)

    Allan
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    Oh - also are you using server-side processing or not?
  • sansan Posts: 4Questions: 0Answers: 0
    edited August 2012
    Hi, Allan! =)
    Thank You for Your reply! =).

    I need to have a posibility to push data into a grid and trigger all events that will update row data, info (10 of 1000 rows are slected), paging info ( << 10 11 12... 30 >>). But with calling a single method. Like it's done in fnServerData when the fnCallback is called.

    So, I expected to have something like [code]oTable.update(response)[/code]. Where response is [code]
    {
    aaData: […],
    iTotalDisplayRecords: 10,
    iTotalRecords: 1000,
    sEcho: "2"
    }
    [/code]

    Sorry for my English =)
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    The way to do that is to call fnDraw and then give the 'fnCallback' method the `response` variable. So you need to have fnServerData able to read that variable.

    Allan
  • sansan Posts: 4Questions: 0Answers: 0
    Thanks, Alan! =) Actually I'm doing it this way. But, it would be much easier to have an external access to fnCallBack.

    Alex
This discussion has been closed.