Solved

jQuery Datatables with server side processing: fnAddDataAndDisplay

Posted on 2013-01-29
5
1,292 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now