How to modify/cutomize the row results rendered in a admin table builders?
Created 7 years ago by srinivas214

Hi, Please help me on below use case in Admin Table builders. How could i apply the filters/ conditions to filter the rows rendered into the table in any admin module index page. For example: In user module, It is rendering all the records from the database, I would need to add one column ("obselete" which has options 1, 0) and i need to render only the rows which has only (obselete = 0 ).

cleancookie  —  7 years ago

You can pass in filter into the tablebuilder, https://pyrocms.com/help/developer-tools/core-concepts/builders

srinivas214  —  7 years ago

Thanks @cleancookie.
But I'm looking to applying the the condition check even with out applying filters. Simply, I would need to write a custom query for example (select * from users where obselete = 0) for rendering the rows of a Table in any admin module.

Is there a way to apply custom query to render the rows in Table Builder? Please help me to solve this.

edster  —  7 years ago

You want to use the onQuerying function in your table builder.

See below example.

/**
     * Fired just before querying
     * for table entries.
     *
     * @param Builder $query
     */
    public function onQuerying(Builder $query)
    {
        $query->where('user_id', Auth::user()->id);
    }
hemanthpyro  —  6 years ago

nice one edster