Solved

jQuery Datatables with server side processing: fnAddDataAndDisplay

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Underline in nav for the page that you are currently on. 1 22
VBScript on Html 15 47
Bootstrap date picker V2 date restriction 6 29
Ahax pagination 9 32
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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)

791 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