Closed vercotux closed 6 years ago
Yes, you can , in config Dynagrid you change 'options' => ['id' => $IdDynagrid]
and you can have the config for each Dynagrid
@metola No you cannot. You misunderstood. I am talking about the module ID, not a table id.
@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.
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.
Ok I will be providing an update for this shortly.
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:
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
@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.
Sorry, took me a while to test. This is PERFECT now. Thank you for your excellent work!
The ID 'dynagrid' should not be hardcoded.