Set data starting from index 1

Set data starting from index 1

hernan84hernan84 Posts: 7Questions: 0Answers: 0
edited March 2012 in DataTables 1.9
Starting from the fact that my html table has 2 more columns than the server-side data in a way to have a first column for row number and a last one for "action" button, I want to set the first data value index=0 on my second table column target=1 therefore I wouldn't loose the first data value on my number column.

What is the good way to make this work??

PS: Hope I explained it well

Replies

  • hernan84hernan84 Posts: 7Questions: 0Answers: 0
    Sorry I found the answer inside the server-side ajax script example: "Use a space where you want to insert a non-database field (for example a counter or static image..."

    So I only had to add a ' ' value to the columns array and that's it.

    [code]
    $aColumns = array( ' '
    , 'a'
    , 'b'
    , 'c'
    , 'd);
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    That's certainly one way of doing it - good to hear you found a solution. Another option is to use mDataProp to tell DataTables which array/object index you want the columns to use and also use sDefaultContent for cells which don't have a database field to display.

    Allan
This discussion has been closed.