KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

How to run Select method #635

Closed Eugene opened this topic on on Jan 30, 2019 - 17 comments

Eugene commented on Jan 30, 2019

Hi,

I would like that by default all options in my Bselect were selected. I used the following and now I have select all option but by default all options are disabled

 "options" => array(
             "includeSelectAllOption" => true,
             "selectAllValue" => 'all',
              ),

Also i've found that to select all by default i have to use the metod .multiselect('selectAll', false); but how to run it from koolreport Bselect?

Regards, Eugene

KoolReport commented on Jan 30, 2019

You do this:

BSelect::create(array(
    ...
    "onReady"=>"function(widget){
        widget.multiselect('selectAll', true);
    }"
))
Eugene commented on Jan 30, 2019

it does not work :-(

KoolReport commented on Jan 30, 2019

May be it should be widget.multiselect('selectAll', false);

Eugene commented on Jan 30, 2019

no... I think something is wrong with the script in the html code it looks like this

...
function(){
    categoriesList = $('#categoriesList');
    var name = categoriesList;
    name.multiselect({"includeSelectAllOption":true,"selectAllValue":"all"});
    name.defaultValue = name.val();
    name.reset = function() {
        var values = name.val();
        name.multiselect('deselect', values);
        name.multiselect('select', name.defaultValue);
    }
    (function(widget) {widget.multiselect('selectAll', false);})(categoriesList);});

KoolReport commented on Jan 30, 2019

Let try this:

BSelect::create(array(
    ...
    "onReady"=>"function(){
        console.log('running after Bselect is ready');
        $('#categoriesList').multiselect('selectAll', false);
    }"
));

Look at the console, it may output the "running..." that make sure that the script is running.

Eugene commented on Jan 30, 2019

It did not help

And I've got the following message in the console for KoolReport.js:106

TypeError: (intermediate value)(...) is not a function                                    
    at (index):182
    at KoolReport.js:105
    at Array.forEach (<anonymous>)
    at Object.checkScriptsAndCallback (KoolReport.js:102)
    at Object.onScriptLoaded (KoolReport.js:88)
KoolReport commented on Jan 30, 2019

Help me to do a thing, go to the line 29 of \koolreport\packages\inputs\BSelect.tpl.php, and add a semicolon there like this:

Line 29:    };

Please let me know if it works.

Eugene commented on Jan 30, 2019

Done. It helped... :-) but i need to click load button to see the report.

KoolReport commented on Jan 30, 2019

We have the defaultParamValues() which you define all default value for multiselect, you need to enter all available values for the multiselect. At first load, your multiselect will have all selected as well as the table will be loaded as well. More info

Eugene commented on Jan 30, 2019

Yes, i thought about it already. But i get the list values from the database. Is it possible to use dataStore for default values?

Eugene commented on Jan 30, 2019

I answer my question: Yes it is possible. I used this topic to write the solution

koolreport can do EVERYTHING!!!

Thanks to developers and support team!

KoolReport commented on Jan 30, 2019

Awesome! I am about to write the same solution, I remember that I answered somewhere but did not find this topic :D

Eugene commented on Jan 30, 2019

:-) Small issue... The page is loaded correct - all items are selected in BSelect and the table is correct

But if I change the selected items and press Load - the table is correct with only new selected categories but the BSelect is again all selected because of onReady function...

KoolReport commented on Jan 30, 2019

Remove the "all select" javascript code and settings, you only need the defaultParamValues()

Eugene commented on Jan 30, 2019

Yes... it works... Sometimes I don't understand how but it works!!!

KoolReport commented on Jan 30, 2019

By using the defaultParamValues() you have filled all the selections by default. If you remove some of selections and Load again, it will disregard the default values ( select all) and stay persistence with your last selections. We made the selections state persistent. Anyway, sometime we only need to know what works and what don't. If things go wrong then we dig deeper to understand why, otherwise leave it :D

Eugene commented on Jan 30, 2019

Thanks for your time

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

Inputs