Hi all,
I have a CCv5 list of data and I need them filter by dynamic dropdown. Max helped me with the code of dynamic dropdown menu:
filtering works fine, data are loaded by filter condiotion. values of dropdown:
Problem is as u can see that the form hasnt empty option so there isnt way how get back all data in list after using of filter. U cant show all data after filtering.
Max give me an advice to modify the line
to this:
after this modification is empty value in dropdown, but filtering doenst work.
As u can see, problem is in values of keys in array, that has 0..2 but the array should looks like previous array.
Array
(
[] =>
[501] => 501
[502] => 502
[553] => 553
)
any idea what is wrong?
thx
I have a CCv5 list of data and I need them filter by dynamic dropdown. Max helped me with the code of dynamic dropdown menu:
$keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($rows, explode(".", "[n].zakladni")), explode(".", "[n].filialka_id"));
$values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($rows, explode(".", "[n].zakladni")), explode(".", "[n].filialka_id"));
$options = array_combine($keys, $values);
$field = array
(
'name' => 'fltr[zakladni][filialka_id]',
'id' => '',
'options' =>
array (
),
'empty' => '',
'values' =>
array (
),
'label' =>
array (
'text' => '',
'position' => 'left',
),
'sublabel' => '',
'multiple' => '0',
'size' => '',
'class' => '',
'title' => '',
'style' => '',
'params' => '',
':data-load-state' => '',
':data-tooltip' => '',
'type' => 'dropdown',
'container_id' => '0',
);
$field["options"] = $options;
echo \GCore\Helpers\Html::formLine($field["name"], $field);
echo '<div class="form-group gcore-form-row" id="form-row-1">
<div class="gcore-input gcore-display-table" id="fin-button3">
<input name="button3" id="button3" type="submit" value="Filtrovat" class="" style="" data-load-state="" />
</div>
</div>';
filtering works fine, data are loaded by filter condiotion. values of dropdown:
Array
(
[501] => 501
[502] => 502
[553] => 553
)
Problem is as u can see that the form hasnt empty option so there isnt way how get back all data in list after using of filter. U cant show all data after filtering.
Max give me an advice to modify the line
$options = array_combine($keys, $values);
to this:
options = array_merge(array('' => ''), array_combine($keys, $values));
after this modification is empty value in dropdown, but filtering doenst work.
Array
(
[] =>
[0] => 501
[1] => 502
[2] => 553
)
As u can see, problem is in values of keys in array, that has 0..2 but the array should looks like previous array.
Array
(
[] =>
[501] => 501
[502] => 502
[553] => 553
)
any idea what is wrong?
thx
Hi Homeopat,
Please try adding this line:
Bob
Please try adding this line:
. . .
$options = array_combine($keys, $values);
array_unshift($options, array( '' => 'Please select')); // add this line
$field = array
. . .
Bob
Hi Bob,
same result, doesnt work
instead of 1,2,3 I need same value so 501,502,503
thx
same result, doesnt work
Array
(
[0] => Array
(
[] => Please select
)
[1] => 501
[2] => 502
[3] => 553
)
instead of 1,2,3 I need same value so 501,502,503
thx
Hi homeopat,
Hmmm . . . then please try this version.
Bob
Hmmm . . . then please try this version.
. . .
$options = array_combine($keys, $values);
array_unshift($options, 'Please select' ); // add this line
$field = array
. . .
Bob
Hi Bob,
it throws this array
and it is wrong. for example, line [1] => 501 should looks like [501] => 501
If I dont use array_unshift or array_merge(array('' => ''), array_combine($keys, $values)); then format is correct:
thank you
it throws this array
Array
(
[0] => Please select
[1] => 501
[2] => 502
[3] => 553
)
and it is wrong. for example, line [1] => 501 should looks like [501] => 501
If I dont use array_unshift or array_merge(array('' => ''), array_combine($keys, $values)); then format is correct:
Array
(
[501] => 501
[502] => 502
[553] => 553
)
thank you
Hi Homepoat,
Bother . . . I think that is because the keys are numeric - so PHP resets them all. Maybe this version . . .
Bob
Bother . . . I think that is because the keys are numeric - so PHP resets them all. Maybe this version . . .
. . .
array_unshift($keys, ''); // add this line
array_unshift($values, 'Please select'); // and this line
$options = array_combine($keys, $values);
$field = array
. . .
Bob
thats it .. thank you bob๐
Hi,
I have one more question. What I have to do If I want use two dropdowns for filtering?
I used previous code, modified name of variables. data are loaded to dropdown, but filtrering doesnt work.
I have one more question. What I have to do If I want use two dropdowns for filtering?
I used previous code, modified name of variables. data are loaded to dropdown, but filtrering doesnt work.
solved. mistake in code.
Hi Homeopat
Do you have a copy of Max's example that I can look at please? I am struggling with this and maybe that would give me a push along. ๐คจ
Thanks
Nick
Do you have a copy of Max's example that I can look at please? I am struggling with this and maybe that would give me a push along. ๐คจ
Thanks
Nick
Hi Homeopat,
Forget that - I cam now follow the code and see that the answer is already there.๐ถ
Regards
Nick
Forget that - I cam now follow the code and see that the answer is already there.๐ถ
Regards
Nick
Hi, I'm new in chronoform and chronoconnectivity.
Can i have the response for this problem? Right code? i have some problem!
ty
Angelo from Italy
๐
Can i have the response for this problem? Right code? i have some problem!
ty
Angelo from Italy
๐
Hi Angelo,
As posted by the original author, the solution posted works well, so if you have the same problem then you can use the same solution, or you may let us know the problem you have exactly so we can try to help!
Regards,
Max
As posted by the original author, the solution posted works well, so if you have the same problem then you can use the same solution, or you may let us know the problem you have exactly so we can try to help!
Regards,
Max
Hi,
I have tried this solution and it works pretty well. But only till the moment I use native pagination of the results (_PAGINATOR_LIST_ ; _PAGINATOR_INFO_; _PAGINATOR_NAV_). Then it dynamically shows only values which are on the current page of listing. Is there any possibility to change the dynamic dropdown list to show all the possible values - from the whole listed table?
Thanks in advance!
I have tried this solution and it works pretty well. But only till the moment I use native pagination of the results (_PAGINATOR_LIST_ ; _PAGINATOR_INFO_; _PAGINATOR_NAV_). Then it dynamically shows only values which are on the current page of listing. Is there any possibility to change the dynamic dropdown list to show all the possible values - from the whole listed table?
Thanks in advance!
Thanks for the topic homeopat (dรญky๐ ), now it works except one detail - I have tried to insert Bob's code (and also tried some modifications) for reseting the filter:
but without any result. Is there any solution how to load the initial list by selecting some default value from the dropdown list?
. . .
array_unshift($keys, ''); // add this line
array_unshift($values, 'Please select'); // and this line
$options = array_combine($keys, $values);
$field = array
. . .
but without any result. Is there any solution how to load the initial list by selecting some default value from the dropdown list?
You mean to select a value at the dropdown when the page loads ?
I will better explain a scenario:
1) I have a full CC listing table without any filter applied and the dynamic dropdown list with loaded IDs from _content table.
2) If I select one ID from the list, and press Submit button, the CC listing table loads only this one record. That's what I wanted.
3) Now I want to go back to the initial state (full CC listing table) by selecting some value from the dropdown list (let's follow Bob's example and the value would be "Please select" and it is on the first place of the dropdown list values). Then after reloading the page (after pressing Submit button) I would like to have back the full CC listing table.
1) I have a full CC listing table without any filter applied and the dynamic dropdown list with loaded IDs from _content table.
2) If I select one ID from the list, and press Submit button, the CC listing table loads only this one record. That's what I wanted.
3) Now I want to go back to the initial state (full CC listing table) by selecting some value from the dropdown list (let's follow Bob's example and the value would be "Please select" and it is on the first place of the dropdown list values). Then after reloading the page (after pressing Submit button) I would like to have back the full CC listing table.
Hi aandree,
Then you may try to change this line:
to:
Regards,
Max
Then you may try to change this line:
$options = array_combine($keys, $values);
to:
$options = array("" => "Please select") + array_combine($keys, $values);
Regards,
Max
This topic is locked and no more replies can be posted.
