Editor With WHERE Conditions (not used for saving data)

Editor With WHERE Conditions (not used for saving data)

lifestylelifestyle Posts: 20Questions: 5Answers: 0

I want to create some filters for the datatable where I can show only a subset of my data... records with a blank e-mail for example. Based on the server-side php scripts, how can I intercept those POST/GET values and then use them in the SQL so that the records in the editable table are constrained to that subset of my data? I don't want the edits to be based on the where statement, just used to show relative data in the editor in the first place...

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Use ajax.data to send the additional values to the server and then just access them as you would with any other POST / GET parameter (depending on which method you are using).

    Allan

  • lifestylelifestyle Posts: 20Questions: 5Answers: 0
    edited August 2014

    I can get the data, but I cannot seem to conditionally add a ->Where , or leave the contents blank...

    My workaround was to use a test of if ( ! isset($_REQUEST['action'])) and then have a new editor instance and query with the where defined and then a second repeated editor instance without the where... doubles up my code... This way table reads use the where, and table edits don't (since it is only relevant to reads)

    Is there a way to conditionally add a WHERE to the editor data source code instead of repeating it (once with for reads and once without for edits)

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    If I understand correctly, I think you just need to break the chain up:

    $editor = Editor:inst( ... )
       ->fields( ... );
    
    if ( isset( $_POST['action'] ) ) {
      $editor->where( ... );
    }
    
    $editor->process( $_POST )->json();
    

    Have I understood correctly?

    Allan

  • lifestylelifestyle Posts: 20Questions: 5Answers: 0

    Perfect.

  • lifestylelifestyle Posts: 20Questions: 5Answers: 0
    edited August 2014

    This works... thanks.

This discussion has been closed.