[{
"caption":"Attribute",
"fields":[
{
"field":"activeSnippet",
"caption":"Module",
"inputTVtype":"listbox",
"inputOptionValues":"Secteurs==1||Contenu==2"
}
]
}]
[
{
"header": "Module actif",
"width": "30",
"sortable": "true",
"dataIndex": "activeSnippet"
}
]
This question has been answered by lucy. See the first response.
Secteurs==1||Contenu==2
@CHUNK inputoptions_snippets
"dataIndex": "renderSnippet"
[[renderActiveSnippet? &snippet=`[[+activeSnippet]]`]]
$snippet = $modx->getOption('snippet',$scriptProperties,'');
$inputoptions = $modx->getChunk('inputoptions_snippets');
$snippets = explode('||',$inputoptions);
foreach ($snippets as $snippetoption){
$snippetoption_parts = explode('==',$snippetoption);
$value = isset($snippetoption_parts[0]) ? $snippetoption_parts[0] : '';
$text = isset($snippetoption_parts[1]) ? $snippetoption_parts[1] : $value;
if ($snippet == $value){
return $text;
}
}
return '';this is one way:
$snippet = $modx->getOption('snippet',$scriptProperties,''); $inputoptions = $modx->getChunk('inputoptions_snippets'); $snippets = explode('||',$inputoptions); foreach ($snippets as $snippetoption){ $snippetoption_parts = explode('==',$snippetoption); $value = isset($snippetoption_parts[0]) ? $snippetoption_parts[0] : ''; $text = isset($snippetoption_parts[1]) ? $snippetoption_parts[1] : $value; if ($snippet == $value){ return $text; } } return '';
$snippet = $modx->getOption('snippet',$scriptProperties,'');
[{"MIGX_id":"1","activeSnippet":"2"},{"MIGX_id":"2","activeSnippet":"99"},{"MIGX_id":"3","activeSnippet":"1"}]
select the renderer 'this.renderChunk' for that columnI don't know where to put this [[renderActive....]] code in the json Gris Columns.
with a render-tpl like
[[renderActiveSnippet? &snippet=`[[+activeSnippet]]`]]
[
{
"dataIndex": "activeSnippet",
"header": "Module actif",
"sortable": "true",
"width": "30"
},
{
"dataIndex": "renderSnippet",
"header": "Render value test",
"sortable": "true",
"renderer": "this.renderChunk",
"???": "[[!renderActiveSnippet? &snippet=`[[+activeSnippet]]`]]",
"width": "30"
}
]
Just for info !
When I use MIGX, I always create MIGX TV in manual way, create from raw json, not by the MIGX Management, I don't know how to use it ! (maybe because I never used it before).
{"field":"nbsType","caption":"Choose Event Type", "inputTVtype":"option","inputOptionValues":"Rehearsal==Rehearsal:rhs||No Rehearsal==No Rehearsal:no-rhs||Concert==Concert:concert","default":"Rehearsal:rhs"}{"header": "Event Type", "width": "50", "sortable": "false", "dataIndex": "nbsType","renderer":"this.renderFirst"}<tr class="[[+nbsType:renderSecond]]"> <td>[[+nbsType:renderFirst]]</td> <td>other fields...</td> <td>other fields...</td> </tr>
<?php
$val = explode(':',$input);
return $val[0];<?php
$val = explode(':',$input);
return $val[1];one==one||two==two|three==three