Renderer question.

Renderer question.

boicenetboicenet Posts: 47Questions: 12Answers: 1

I have the following code that works great; however, it displays more records than I'd like (all records from the database table). I'd rather limit the returned data to columns equal to a specific value. Similar to a where clause (where x.id = "1"). Is this possible to accomplish with a renderer?

                        columnDefs: [
                            {
                                // The `data` parameter refers to the data for the cell (defined by the
                                // `data` option, which defaults to the column being worked with, in
                                // this case `data: 0`.
                                "render": function ( data, type, row ) {
                                    return ''+ row.users.full_name +'';
                                },
                                "targets": 14
                            },


This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,822Questions: 1Answers: 10,517 Site admin

    Not with a renderer (which just renders existing data and doesn't filter at all). But if you are using the Editor PHP libraries, you can apply a WHERE condition which will do what you want. Documentation for that is available here.

    Allan

  • boicenetboicenet Posts: 47Questions: 12Answers: 1

    Thanks, Allan.

    I read the documentation you referenced, but cannot figure out where exactly to place the WHERE condition code. I want to filter the data displayed in a dropdown list on the editor form.

  • allanallan Posts: 63,822Questions: 1Answers: 10,517 Site admin
    Answer ✓

    I want to filter the data displayed in a dropdown list on the editor form.

    Oh - sorry. I misunderstood. That's in a different section of the documentation in that case. The forth parameter passed into the options() method can be used as a WHERE condition for the options shown in the list.

    Allan

  • boicenetboicenet Posts: 47Questions: 12Answers: 1

    Excellent! Thank you, Allan. Your advice works great as usual!

This discussion has been closed.