Adding DT_RowId
Adding DT_RowId
Using server-side and need to make use of DT_RowId. From what I can tell I need to do this in my server-side processing. I am using the default script with 1.10 and cannot figure out how to add this in... I just want to use my $primaryKey column value as the value for DT_RowId. I believe I should be doing this in 'static function data_output'?
[code]
static function data_output ( $columns, $data )
{
$out = array();
for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
$row = array();
for ( $j=0, $jen=count($columns) ; $j<$jen ; $j++ ) {
$column = $columns[$j];
// Is there a formatter?
if ( isset( $column['formatter'] ) ) {
$row[ $column['dt'] ] = $column['formatter']( $data[$i][ $column['db'] ], $data[$i] );
}
else {
$row[ $column['dt'] ] = $data[$i][ $columns[$j]['db'] ];
}
}
$out[] = $row;
}
return $out;
}
[/code]
[code]
static function data_output ( $columns, $data )
{
$out = array();
for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
$row = array();
for ( $j=0, $jen=count($columns) ; $j<$jen ; $j++ ) {
$column = $columns[$j];
// Is there a formatter?
if ( isset( $column['formatter'] ) ) {
$row[ $column['dt'] ] = $column['formatter']( $data[$i][ $column['db'] ], $data[$i] );
}
else {
$row[ $column['dt'] ] = $data[$i][ $columns[$j]['db'] ];
}
}
$out[] = $row;
}
return $out;
}
[/code]
This discussion has been closed.
Replies
[code]$row[ 'DT_RowId' ] = $data[$i][ $columns[0]['db'] ];[/code]
will set DT_RowId to the primary key value for each row. I am doing this right before $out[] = $row;
Assuming your first column is the same as your primary key.