Server side version of $.fn.dataTable.ext.search

Server side version of $.fn.dataTable.ext.search

Hi!

Is there any server side version of $.fn.dataTable.ext.search?

I have my datatable behind a login page and only want to show rows that been created by the end user that is logged in. I have a column with "creater_id" on each row to know which row that belongs to what user. I assume I can use $.fn.dataTable.ext.search to filter results to only match the user id before end user can serach or see any results. But is there any server side version of that? I assume that would be safer then to set a filter on client side.

Answers

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin

    Is there any server side version of $.fn.dataTable.ext.search?

    Apply an additional WHERE condition whatever server-side script you are using.

    Allan

  • arvidsson.andreas@gmail.comarvidsson.andreas@gmail.com Posts: 3Questions: 2Answers: 0

    Thanks Allan! I´m using php and mysql and have installed the file structure from your generator. So I assume the extra WHERE condition should be added in the file called "Query.php" and by changing the following code block:

        public function and_where ( $key, $value=null, $op="=", $bind=true )
        {
            return $this->where( $key, $value, $op, $bind );
        }
    

    But I have to admit I probably missunderstand something fundemental here. I don´t understand how or where to manipulate the $key and $value variables? Lets´s say $key = "creator" and the $value = $_SESSION['logedinuser'], where do I set this?

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin

    Ah! If you are using Editor's PHP libraries, then have a look at the documentation here. That is how you would apply conditions such as the ones you are looking for.

    Allan

This discussion has been closed.