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

sortableAttribute as getter in CActiveDataProvider #946

Open
cfuturesgroup opened this issue Sep 10, 2014 · 1 comment
Open

sortableAttribute as getter in CActiveDataProvider #946

cfuturesgroup opened this issue Sep 10, 2014 · 1 comment

Comments

@cfuturesgroup
Copy link

I want use getter in CActiveRecord as sortableAttribute. For do this please change in TbExtendedGridView

    /**
     *### .getAttribute()
     *
     * Helper function to get an attribute from the data
     *
     * @param CActiveRecord $data
     * @param string $attribute the attribute to get
     *
     * @return mixed the attribute value null if none found
     */
    protected function getAttribute($data, $attribute)
    {
        if ($this->dataProvider instanceof CActiveDataProvider)
        {
            if ($data->hasAttribute($attribute))
            {
                return $data->{$attribute};
            }
            $method = 'get' . ucfirst($attribute);
            if (is_object($data) && method_exists($data, $method))
            {
                return call_user_func([$data, $method]);
            }
        }

        if ($this->dataProvider instanceof CArrayDataProvider || $this->dataProvider instanceof CSqlDataProvider) {
            if (is_object($data) && isset($data->{$attribute})) {
                return $data->{$attribute};
            }
                        if (isset($data[$attribute])) {
                return $data[$attribute];
            }
        }
        return null;
    }
@amrbedair
Copy link
Contributor

what is this ... what do you need ...!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants