Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error will be occured when call makeCustomButton method #51

Closed
bbbbbbbk opened this issue Jun 6, 2018 · 5 comments · Fixed by #52
Closed

An error will be occured when call makeCustomButton method #51

bbbbbbbk opened this issue Jun 6, 2018 · 5 comments · Fixed by #52
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@bbbbbbbk
Copy link

bbbbbbbk commented Jun 6, 2018

Appreciate for this project, it helps a lot!
And I find that an error will be occured when I call makeCustomButton like this(the parameter seems should be 'rows' but not 'row'):

$this->makeCustomButton([
    'name' => 'home',
    'url' => url('/'),
 ],'rows');

And after I set a renderIf attribute it works,like this:

$this->makeCustomButton([
    'name' => 'home',
    'url' => url('/'),
    'renderIf' => function(){
        return true;
    }
],'rows');
@leantony
Copy link
Owner

leantony commented Jun 6, 2018

Try;

$this->makeCustomButton([
    'name' => 'home',
    'url' => url('/'),
    'renderIf' => function(){
        return true;
    }
], static::$TYPE_ROW);

Sorry, some of the docs are abit behind, but will update them

@bbbbbbbk
Copy link
Author

bbbbbbbk commented Jun 8, 2018

And I find that I must set the tableColumns attribute if I want use filters, like:

protected $tableColumns = [
    'id',
    'title',
    'status'
];

isn't in docs

@leantony
Copy link
Owner

leantony commented Jun 8, 2018

If you want to filter, use this approach, as documented here
Assuming you want to display the columns {id, name and email} on the grid and a filter for them..

/**
     * Set the columns to be displayed.
     *
     * @return void
     * @throws \Exception if an error occurs during parsing of the data
     */
    public function setColumns()
    {
        $this->columns = [
            "id" => [
                "label" => "ID",
                "filter" => ["enabled" => true, "operator" => "="],
                "styles" => ["column" => "grid-w-10"]
            ],
            "name" => [
                "search" => ["enabled" => true],
                "filter" => ["enabled" => true, "operator" => "="]
            ],
            "email" => [
                "search" => ["enabled" => true],
                "filter" => ["enabled" => true, "operator" => "="]
            ],
        ];
    }

The filter attribute on each column is used to create a filter. Do not use tableColumns as that is used internally for column verification.
The method public function setColumns() already exists on your grid class. It is used to make changes to the columns that will be displayed on the UI.

I will be updating the docs, fixing typos, etc to minimize the confusion.

@bbbbbbbk
Copy link
Author

bbbbbbbk commented Jun 8, 2018

OK,thanks.Here's another problem,when I use filter the filter will skip value 0,but there are attributes like status contains 0, I've viewed the source code and noticed the problem was caused by here:

    /**
     * Check if provided user input can be used
     *
     * @param string|null $userInput
     * @return bool
     */
    public function canUseProvidedUserInput($userInput)
    {
        // skip empty requests
        if ($userInput === null || empty(trim($userInput))) {
            return false;
        }
        return true;
    }

In RowFilterHandler.php line 83, the method canUseProvidedUserInput will return false when $userInput is 0 but not empty

@leantony
Copy link
Owner

leantony commented Jun 8, 2018

Thanks. I will look into that

@leantony leantony self-assigned this Jun 8, 2018
@leantony leantony added bug Something isn't working question Further information is requested labels Jun 8, 2018
leantony added a commit that referenced this issue Jun 8, 2018
leantony added a commit that referenced this issue Jun 8, 2018
@leantony leantony mentioned this issue Jun 8, 2018
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants