Empty List collector ?

sandaru
Giga Contributor

Hi,

I'm in a need of creating an empty list collector. Since we cannot initiate an empty list controller, what i'm going to do is run an onLoad script to remove all the elements from the List collector and add it manually via   a script.

Can i do this ? and how to do that ?

All the way i searched i only found some thing called "move" which moves elements from left to right and vise versa.

Thank you.

/Sandaru

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

Here is how you can do it. You will have use filter string sys_id=''; This will load you with empty list collector


function onLoad() {


    //Apply a default filter to the list collector variable


    var collectorName = 'configuration_items';


    var filterString = 'sys_id='+'';


    //Hide the list collector until we've set the filter


    g_form.setDisplay(collectorName, false);


    setCollectorFilter();


 


    function setCollectorFilter(){


          //Test if the g_filter property is defined on our list collector.


          //If it hasn't rendered yet, wait 100ms and try again.


          if(typeof(window[collectorName + 'g_filter']) == 'undefined'){


                setTimeout(setCollectorFilter, 100);


                return;


          }


          //Find the filter elements


          var fil = gel('ep');


          //Hide the filter elements by un-commenting the following lines


          /*fil.rows[0].style.display = 'none';


          fil.rows[1].style.display = 'none';


          fil.nextSibling.rows[0].style.display = 'none'; //Filter description text*/


       


          //Reset the filter query


          window[collectorName + 'g_filter'].reset();


          window[collectorName + 'g_filter'].setQuery(filterString);


          window[collectorName + 'acRequest'](null);


          //Redisplay the list collector variable


          g_form.setDisplay(collectorName, true);


    }


}


View solution in original post

8 REPLIES 8

Abhinay Erra
Giga Sage

Here is how you can do it. You will have use filter string sys_id=''; This will load you with empty list collector


function onLoad() {


    //Apply a default filter to the list collector variable


    var collectorName = 'configuration_items';


    var filterString = 'sys_id='+'';


    //Hide the list collector until we've set the filter


    g_form.setDisplay(collectorName, false);


    setCollectorFilter();


 


    function setCollectorFilter(){


          //Test if the g_filter property is defined on our list collector.


          //If it hasn't rendered yet, wait 100ms and try again.


          if(typeof(window[collectorName + 'g_filter']) == 'undefined'){


                setTimeout(setCollectorFilter, 100);


                return;


          }


          //Find the filter elements


          var fil = gel('ep');


          //Hide the filter elements by un-commenting the following lines


          /*fil.rows[0].style.display = 'none';


          fil.rows[1].style.display = 'none';


          fil.nextSibling.rows[0].style.display = 'none'; //Filter description text*/


       


          //Reset the filter query


          window[collectorName + 'g_filter'].reset();


          window[collectorName + 'g_filter'].setQuery(filterString);


          window[collectorName + 'acRequest'](null);


          //Redisplay the list collector variable


          g_form.setDisplay(collectorName, true);


    }


}


This one is working


Thank you.


Abhinay Erra
Giga Sage

Most simpler way to remove all the options from list collector. Add these 3 lines in your onLoad client script


var varName = 'YOUR_VARIABLE_NAME_HERE';


var leftBucket = gel(varName + '_select_0');


var rightBucket = gel(varName + '_select_1');


rightBucket.options.length=0;


leftBucket.options.length=0;


This is not working I have tried it