Sorting Error for the Column with Data from Joined Table

Sorting Error for the Column with Data from Joined Table

poeziafreepoeziafree Posts: 35Questions: 11Answers: 0

Hello,

I am using the DataTables Editor Join functionality.

For the column that displays data from the joined table, the sorting cannot be performed.

Test Case: https://delivery.statiebi.com/datatable-editor/examples/extensions/searchBuilder.html

Column Name using the data from the joined table: Start Date

PHP Code:

`<?php

/*
* Example PHP implementation used for the index.html example
*/

// DataTables PHP library
include( "../lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'users' )
->fields(
Field::inst( 'users.id' ),
Field::inst( 'users.operator' ),
Field::inst( 'users.name' ),
Field::inst( 'users.surname' ),
Field::inst( 'users.active' ),
Field::inst( 'users.department' ),
Field::inst( 'users.pin' ),
Field::inst( 'users.email' ),
Field::inst( 'users.threshold' ),
Field::inst( 'users.date_last' )
)
->join(
Mjoin::inst( 'user_feedback' )
->link( 'user_feedback.operator', 'users.operator' )
->order( 'user_feedback.time asc' )
->where( 'user_feedback.time', 1633101482, '=')
->fields(
Field::inst( 'score' )
->set( false )
)
)
//->where( 'user_feedback.time', 1633101482, '=')
->debug(true)
->write(false)
->process( $_POST )
->json();
`

Answers

  • poeziafreepoeziafree Posts: 35Questions: 11Answers: 0

    Hi @allan

    Is there any mistake on my part?

    Please, help me...

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Are you using server-side processing? Unfortunately, an Mjoin with server-side processing does not sort (indeed, I'm not actually sure what the correct implementation for this would be, since your be sorting first by the inner array in each row and then the contents of that array compared to other rows - does it use the first number, an average or something else).

    With client-side processing it will sort, but it will be string based if you have non-numeric data visible.

    Allan

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Sorry - I see you are using server-side processing. So yes, that is the issue.

    You only have 8 records though - unless you are expecting it to grow to at least tens of thousands of rows, then just disable server-side processing.

    Allan

  • komeyria55komeyria55 Posts: 1Questions: 0Answers: 0

    Hi, i am also faced this issue. it is tough

Sign In or Register to comment.