How to use Editor on filtered tables .

How to use Editor on filtered tables .

naktunaktu Posts: 6Questions: 4Answers: 0

With full access to a table Editor working flawlessly.

I couldnt find any reasonable approach to use editor on a single table which is filtered.
I have a table with a user id column (items_of_all_users). I want to show each user, their rows (items) corresponding to thier ids.
When 6th user execute editor, s/he will only see rows if( items_of_all_users.user_id == 6 ) . s/he will be able to edit it , insert new row and all that editor functions. Naturally, any any row edited, shown, inserted must have user_id == 6.

This is a table created by many to many relationship so it has 2 primary key. i know datatables do not hendle multiple pk.s .

So; can i just create a derived (views maybe) tables editable by users ?
I created php scripts which take a user_id and run sql codes filtering table and sending them to data table to populate via ajax. But i just bumped the editing part of this process.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,722Questions: 1Answers: 10,108 Site admin
    Answer ✓

    Hi,

    Assuming you are using the PHP libraries for Editor, the documentation for how to apply a where condition is available here. Likewise, the .NET libraries have similar documentation if you are using .NET.

    Allan

  • naktunaktu Posts: 6Questions: 4Answers: 0
    edited March 2017
    Editor::inst( $db, 'table', 'PKcolumn' )
        ->fields(
            Field::inst( 'col1' ),
            Field::inst( 'col2' ),
            Field::inst( 'col3' )
        )->where( 'col3', $filterValue ) 
        ->process( $_POST )
        ->json();
    

    Only rows which has filtervalue in col3 will be shown.
    I will use ->set() for insert operations.

This discussion has been closed.