mgallegos / laravel-jqgrid

@Laravel jqGrid package allows you to easily integrate the popular @jQuery Grid Plugin (jqGrid) into your Laravel application.
mariogallegos.com
Other
69 stars 44 forks source link

may be include new method fo prepare select-list ? #35

Open KrasilnikovKB opened 8 years ago

KrasilnikovKB commented 8 years ago

some like this:

   public function prepareSelect_jqGrid( $data, $first = null){
        if(!is_null($first)){
            $data->prepend($first, '');
        }

        $base = array();
        foreach($data as $k => $v){
            $base[] = $k . ':' . $v;
        }

        return '\'' . implode(';', $base) . '\'';
    }

now we can prepare SELECT from lists :

$listUsers = $this->prepareSelect_jqGrid(User::where('enabled', true)->get()->pluck('full_name', 'id'), ' - ALL - ');

..........................

                      ->addColumn([
                                            'label'=>'User full name',
                                            'index'=>'user_id',
                                            'align'=>'left',
                                            'width' => 300,
                                            'fixed' => false,
                                            'editable' => true,
                                            'editrules' => ['required' => true],
                                            'edittype' => 'select',
                                            'formatter' => 'select',
                                            'editoptions' => [
----------------------------------------------->     'value' => $listUsers,
                                                                'style' => 'width: 90%;',
                                                             ]
                                           ]
                                  )
mgallegos commented 8 years ago

Why don't you work on your idea, and send a pull request?

KrasilnikovKB commented 8 years ago

i am noob in laravel fasades :(

may you add facade + empty implementation for some static helper-functions ?

name for example : RenderUtils

first need method (generate json-list for select-type column) :

    static public function prepareSelectList($data, $first = null){
        if(!is_null($first)){
            $data->prepend($first, '');
        }

        $base = array();
        foreach($data as $k => $v){
            $base[] = $k . ':' . $v;
        }
        return implode(';', $base);
    }

on stage there thinking about adding new functionality facilitates work with daterange filter for columns with dates