Arrange columns in a proper order

Arrange columns in a proper order

victoreadwardvictoreadward Posts: 7Questions: 0Answers: 0
edited September 2013 in General
Hi, how could I arrange columns in a different order than that json brings?

I tried this (order needed):

[code]Name
Instance Dir
Data Dir
Start Time
Uptime
Current
Has Deletions
Last Modified
Max Doc
Num Docs
Optimized
Version[/code]

And in the JS:

[code]'aoColumnDefs': [
{'sName': 'name', 'aTargets': [0]},
{'sName': 'instanceDir', 'aTargets': [1], 'bVisible': false},
{'sName': 'dataDir', 'aTargets': [2], 'bVisible': false},
{'sName': 'startTime', 'aTargets': [3], 'sWidth': '200px'},
{'sName': 'uptime', 'aTargets': [4]},
{'sName': 'index.numDocs', 'aTargets': [5]},
{'sName': 'index.maxDoc', 'aTargets': [6]},
{'sName': 'index.version', 'aTargets': [7]},
{'sName': 'index.optimized', 'aTargets': [8]},
{'sName': 'index.current', 'aTargets': [9]},
{'sName': 'index.hasDeletions', 'aTargets': [10]},
{'sName': 'index.lastModified', 'aTargets': [11], 'sWidth': '200px'}
],
'aoColumns': [
{'mDataProp': 'name'},
{'mDataProp': 'instanceDir'},
{'mDataProp': 'dataDir'},
{'mDataProp': 'startTime'},
{'mDataProp': 'uptime'},
{'mDataProp': 'index.numDocs'},
{'mDataProp': 'index.maxDoc'},
{'mDataProp': 'index.version'},
{'mDataProp': 'index.optimized'},
{'mDataProp': 'index.current'},
{'mDataProp': 'index.hasDeletions'},
{'mDataProp': 'index.lastModified'}
],[/code]

But the column headers stay in order while rows are confused. For instance, Last Modified infor is under Version header, Uptime, Current and Has Deletions information are under, Max Doc, Num Docs and Optimized headers.

What is going on?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Just change your mDataProp values. The whole point of mDataProp is that you can use whatever property from the source object you want since the source object has no order.

    Allan
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It would also be worth just using aoColumns - not aoColumnDefs as well since you are just defining every column any way.

    Beyond that, please link to a test case.

    Allan
  • victoreadwardvictoreadward Posts: 7Questions: 0Answers: 0
    Oh my God! Sorry. I foolishly did not even realize I had changed the order of columns.

    Thank you.

    VE
This discussion has been closed.