No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Picklist Filter Editor - Get number of records from the Pick List

    Click image for larger version  Name:	Screen Shot 2020-03-27 at 7.50.44 AM.png Views:	0 Size:	153.9 KB ID:	261587

    Im Have a Picklist with a filter editor. When I type in the filter editor, the filtering happens locally.
    Requirement: need the number of records which shows in the pick list to determine if its empty or not.

    I tried to achieve this using a FilterEditorSubmitHandler

    ComboboxItem equipmentProfile = new ComboBoxItem("profileCode", "Equipment Profile);
    /* assume i have created a new "pickListProperties", it contains all fields*/
    pickListProperties.addFilterEditorSubmitHandler(new FilterEditorSubmitHandler() {
    public void onFilterEditorSubmit(FilterEditorSubmitEvent filterEditorSubmitEvent) {
    if (equipmentProfile.filterClientPickListData().length == 0) {
    SC.say("1: " + String.valueOf(equipmentProfile.filterClientPickListData().length));
    } else {
    SC.say("2: " + String.valueOf(equipmentProfile.filterClientPickListData().length));

    I noticed equipmentProfile.filterClientPickListData().length gives random counts when typing in the pick list filter editor.

    Please be kind to give a solution to achieve this.
    Last edited by AnutharshaSelvarasa; 26th Mar 2020, 18:49.

    By design, FilterEditorSubmit fires when criteria are changed but before filtering has occurred, so the results are not random, but if you read the docs for the event, checking the data length at this time is obviously not what you want. Also, filterClientPickListData() only applies to non-databound ComboBoxItems, so that's also probably not appropriate here.

    The DataChanged event would be one place to check and update the dataset length, but, your approach is in general not supported and not supportable, and there is a warning in your Developer Console telling you this. The reason is that use a filterEditor on a ComboBoxItem's pickList leads to an ambiguous user experience as the two sets of filter-criteria (those from the text-box and those from the pickList filter editor) interact with each other.

    You can achieve multi-field filtering via just setting comboBoxItem.filterFields, or, the FilterEditor is supported for SelectItem since in that case there is no user experience issue. Finally, consider a pop-up dialog instead if more filtering options need to be available for this field.

    Please be sure to have your Developer Console open while developing so that you don't miss warnings like this in the future. It will save a lot of time.


      so this is not doable using the ComboBoxItem ?



        We just explained that it makes no sense to attempt this, and provided alternative approaches that do make sense.