Solved

jQuery Datatables with server side processing: fnAddDataAndDisplay

Posted on 2013-01-29
5
1,354 Views
Last Modified: 2013-02-05
I am using datatables 1.9 with server side processing.  I would like to add new records and display the newly added records.  When not using server side processing I can use the fnAddDataAndDisplay() function.  

Is there a method or technique similar to fnAddDataAndDisplay() that works with server side processing?

For instance, I could add the record - locate the record with a query - and have datatables go to the correct page.  However, I can not locate a method to make datatable go to the page I want.

Thanks!
0
Comment
Question by:HyperBPP
  • 4
5 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 500 total points
ID: 38833902
0
 
LVL 6

Author Comment

by:HyperBPP
ID: 38835774
Almost works.  However, adds the row to the displayed rows and sorts based on the displayed rows rather than all data available on server side.  Probably not a function to work with the server side data.... hmmm.

However, the iDisplay start propery may be what I'm looking for.   this would let me go to the desired page.  I just may have to do an extra server side call to calculate the page and write an extra server side source page that does this.

But, I need to know if my table is using server side processing or not.  I have both types of tables in my app.  Know of a property that can True/False the server side of the table?
0
 
LVL 6

Author Comment

by:HyperBPP
ID: 38835804
Ah-ha!

oSettings.oFeatures.bServerSide
0
 
LVL 6

Accepted Solution

by:
HyperBPP earned 0 total points
ID: 38840553
So I created a server side and made an ajax call on once the data was added and update the table to the position

queryString = '?iDisplayLength=' + oSettings._iDisplayLength + '&iSortingCols=1' + 
						'&sSearch=' + oSettings.oPreviousSearch.sSearch  + '&sSortDir_0=' + oSettings.aaSorting[0][1] +
						'&iSortCOL_0=' + oSettings.aaSorting[0][0] + '&record=' + response["UUID"] + 
						'&name=' + $.urlParam('name');

$.ajax({
					url:'DB/CFM/dataTablePositionAjaxForm.cfm' + queryString,	
					dataType:"json",
					success: function(data, textStatus,jqXHR){
						//go to position
						
						alert(data["sStart"]);
						oSettings._iDisplayStart = data["sStart"] - 1;
						oSettings.oApi._fnDraw( oSettings );
						
						
					}});

Open in new window

0
 
LVL 6

Author Closing Comment

by:HyperBPP
ID: 38854303
Posted the final answer.  Leakim's answer contributed to the knowledge.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question