Various default features not working.
Various default features not working.
This is a great plugin! I am still somewhat new to it, and as such and I am having some trouble. I have implemented a page that combines Datatables and Jeditable. Mostly it is working quite well, however, some of the default functions are not working. First, numeric sorting works well until I add a new row, then it reverts to "alphabet" type sorting. I have tried the numeric sorting plugin to no avail. Second, the state saving function doesn't work. If I go forward several pages and edit a record, once the record is saved it reverts to page one. Third, even though I have used the demos.css code and have formatted my code with all of the same id and class names, I cannot get the icons for the sort indicators on the columns to appear. Also, as I am still new to datatables, if you see anything that I could improve, please feel free to let me know. Thanks in advance. Code sample here: http://pastebin.com/m53caeff2
This discussion has been closed.
Replies
A number of questions there - I'll try and separate them out :-)
1. Numeric sorting until adding a new row - are you using the latest 1.5 beta? There was a time (can't remember off the top of my head) where it would revert to type 'string' when you add a new row - but this has been addressed now.
2. Custom sorting type - you have "num-html" sorting functions in your Javascript, but nothing telling DataTables to use them. You either need to define that explicitly with aoColumns.sType, or have a type detection function.
3. State saving - your code doesn't show this feature as enabled. It is off by default, so you need to enable it with bStateSave ( http://datatables.net/usage#bStateSave ). If this fails then check for a cookie with the prefix "SpryMedia_DataTables_"
4. Styles - What information does Firebug (or something similar) show? Are the image styles applied, and it just can't locate the images, or do you need to modify the selectors to match your HTML?
Hope this helps,
Allan
2. I wondered about explicitly defining that, but I saw nothing about it in the plugin documentation for it. I'll look into that.
3. I was under the impression that it was enabled by default. http://www.datatables.net/usage -- details for bStateSave. However, I have tried it with explicit enabling and it still doesn't work.
4. This turned out to be a permissions problem on the server. Oops!
Thanks for getting back so quickly!
a is not defined
http://10.10.0.14/Heritage/index.php
Line 18
var x = a.replace( /<.*?>/g, "" );
Am I missing something? Should a and b be x and y?
2. Perhaps this example will help: http://datatables.net/1.5-beta/examples/api/sorting_plugin.html
3. Sorry about that - I can see why you were under that impression :-). The documentation for there is out of data (and has been for some time...) I have updated it now to show that the default state is off.
4. Good stuff.
Allan
Allan
2. The code at http://datatables.net/1.5-beta/examples/api/sorting_plugin.html shows the same change that I made, changing x,y in the function definition to a, b.
3. I have now explicitly defined it, and it still doesn't work.
3. Is the cookie I mentioned created? If not, then that's the problem. If so, then the question is, does it contain valid JSON?
3. No, I did not create the cookie. I will try that. I didn't know that it was explicitly required. I reread the documentation and while it mentions the cookie, it doesn't say that it is required.
So what sounds like is happening for you is that on the update the redraw is causing the paging to go back to the start (i.e. when you update the table). This is because DataTables is doing a full redraw when you do the update. The reason for this is that the information in the column being sorted upon might have changed - and therefore a resort is required.
If you don't want this to happen you can pass "false" as the fourth parameter for fnUpdate ( http://datatables.net/api#fnUpdate ) to tell DataTables not to redraw the table. And hopefully that will do what you are looking for now.
Allan
I think you have two options here:
1. You can make use of an API function I've just added to the plug-ins page called fnDisplayRow() ( http://datatables.net/plug-ins#api_fnDisplayRow ). This function will take a TR node as a parameter and alter the table's paging to show the row.
2. fnAddData() also has a 'do not redraw' parameter (pass 'false' as the second parameter). This isn't documented yet as it is only available in 1.5, which is currently in beta.
Regards,
Allan