Dynamically populate/clear a List

Posted by: waldo on 21 November 2021, 5:48 pm EST

  • Posted 21 November 2021, 5:48 pm EST

    Hi,

    How do you dynamically or programmatically populate or clear a List?

    I created a sidepanel UI and in it is a List with hard coded items

    
      {
      type: "List",
      bindingPath: "list1",
      id: "gc_list",
      className: "gc_list_container",
      items: [
        { text: 'Item 1', value: '1' },
        { text: 'Item 2', value: '2' }
      }
    
    

    Looking at the code I see there is a way to create a List like the code below but the API documentation does not show where to access this.

    
    var d = new C.List(this.root, {
    	type: "List",
    	items: n.listContent,
    	command: n.commandName,
    	maxHeight: n.dropdownMaxHeight,
    	wrap: !0,
    	maxWidth: n.maxWidth,
    	direction: 0,
    	align: 0,
    	useCapture: !1,
    	allowSelection: !1
    });
    
    

    An instance of this List seems to have methods/properties listed below that will be usefully to programmatically populate and control the List.

    • updateValue
    • selectedIndex
    • itemsCount
    • _items

    I’m aware you can Add a Custom Component but seeing that there is already an existing List component, it seems possible to to use this existing component.

    In addition there seems to be a multiSelectList as well. Any tip in using that will be helpful as well.

    Thank you

  • Posted 22 November 2021, 8:18 pm EST

    Hi Waldo,

    We are sorry but the List type is an internal type, we cannot use it directly in the code. The only way to define a list is by specifying the List type in the config. It does not support dynamic values, after updating the list values, you need to register the component/dialog.

    For supporting dynamic values, you need to create a custom component by inheriting from the AtomicComponent:

    https://www.grapecity.com/spreadjs/docs/v14/online/add-custom-component.html

    Regards

    Sharad

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels