Solved

jQuery Datatables with server side processing: fnAddDataAndDisplay

Posted on 2013-01-29
5
1,368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 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)
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…

726 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