Save layout of data including sorting,column width,Hide/Show etc.

Save layout of data including sorting,column width,Hide/Show etc.

samdemosamdemo Posts: 16Questions: 0Answers: 0
edited October 2013 in General
Hi,

I am using server side processing with scroller, check box for hide/show column.
My code:
var oTable = $('#example').dataTable( {
"sScrollY": "150px",
"sAjaxSource": "/ExampleDataTableJSON/FeedServlet",
"bServerSide": true,
"sDom": "RfrtiS",
"oScroller": {
"loadingIndicator": true
},
"aoColumns": [
{ "mData": "engine" },
{ "mData": "browser" },
{ "mData": "platform"},
{ "mData": "version"},
{ "mData": "grade"}
]
} );
I want to store existing layout(JSON) into database(Including Sorting,Column width and Hide/Show column) ,can anyone help me by giving any example.
I have tried fnServerData but i am not able to figure out whats happening.

Thanks
Sam

Replies

  • samdemosamdemo Posts: 16Questions: 0Answers: 0
    Hi,
    One addition in my above comments, I wanted to save layout on button click.

    Thanks
    Sam
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You would need to use fnStateLoadParams and fnStateSaveParams to save the additional information that you want. DataTables built in state saving will save only the sorting state from the list that you provided, so you'd need to add some code and state information to add the extra abilities.

    Allan
  • samdemosamdemo Posts: 16Questions: 0Answers: 0
    Hi allan,
    Thank you for your suggestion. I will manage column width later but right now i am using:
    fnStateSave": function (oSettings, aoData ) {}
    When alert aoData I got Something like this:
    alert("aoData" +JSON.stringify(aoData));
    Output:
    aoData{"iCreate":1383133868178,"iStart":0,"iEnd":0,"iLength":63,"aaSorting":[[0,"asc",0]],"oSearch":{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},"aoSearchCols":[{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true},{"bCaseInsensitive":true,"sSearch":"","bRegex":false,"bSmart":true}],"abVisCols":[true,true,true,true,true],"iScroller":0,"ColReorder":[0,1,2,3,4]}

    I need Sortorder, SortName, ColName, ColModel

    What is my scenario let me clear Allan, My current application is using jqgrid i am trying to replace with datatable.
    I am saving layout by converting JSON to XML and using AJAX to store layout in database
    jqgrid gives me Sortorder, SortName, ColName, ColModel directly
    e.g var colNames = $("#ID").jqGrid('getGridParam','colNames');

    I can apply same logic if i get all this values using aoData or in some other way.
    I request you to suggest me some solution for this.

    Thanks
    Sam
This discussion has been closed.