kartik-v / yii2-dynagrid

Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.
http://demos.krajee.com/dynagrid
Other
74 stars 66 forks source link

Unable to have multiple dynagrid module configurations #170

Closed vercotux closed 6 years ago

vercotux commented 6 years ago

The ID 'dynagrid' should not be hardcoded.

metola commented 6 years ago

Yes, you can , in config Dynagrid you change 'options' => ['id' => $IdDynagrid] and you can have the config for each Dynagrid

vercotux commented 6 years ago

@metola No you cannot. You misunderstood. I am talking about the module ID, not a table id.

kartik-v commented 6 years ago

@vercotux I will need to understand this better. The module identifier named dynagrid is important for the various controller actions to work properly in the module. Can you suggest a use case why you would want the module identifier to be different? Note that if you are wondering on changing this for the module actions and url generated - then you can use Yii's URL manager rules to change the url generated for all the module actions.

vercotux commented 6 years ago

A few common scenarios:

Either way, hardcoding the id is a "quick fix" (yii devs said this) and not a good solution as it violates the SOLID principle. It should be avoided at all cost. It is better to allow dynamic id and require the module to be bootstrapped in case its resources are needed from unpredictable locations.

kartik-v commented 6 years ago

Ok I will be providing an update for this shortly.

kartik-v commented 6 years ago

Now with this enhancement... you can set Dynagrid::moduleId to your own module id set in your configuration file (you can use relative naming for grand children). If this property is not set - it will use the Module::getInstance method - ELSE default to dynagrid if no module found. Check below:

https://github.com/kartik-v/yii2-dynagrid/blob/7435f3118c8bc048d5c607e363424f57b8599746/DynaGrid.php#L71-L77

lipin commented 6 years ago

yii2-dynagrid/DynaGridDetail.php && yii2-grid/GridView.php When I used it, I found it needed to add this line to the two files above, public $moduleId; or else it would Setting unknown property: kartik\dynagrid\DynaGridDetail:: moduleId Setting unknown property: kartik\grid\GridView:: moduleId Please make sure this is the case

kartik-v commented 6 years ago

@lipin this is not correct... you need to UPDATE your packages via COMPOSER... to ensure you get the latest release of these extensions with their dependencies.

vercotux commented 6 years ago

Sorry, took me a while to test. This is PERFECT now. Thank you for your excellent work!