Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

How to clear the combobox value if I move to next values in the grid

(0) ShareShare
ReportReport
Posted on by 1,873
Hello,
 
I have a grid in the left side of the form which display data of some IDs. I have also combobox in DetailsHeader(Group) and its display weekdays. Here I need to clear the combobox and edit the combobox as manually once the value of Ids controller changed in the grid. For next Id2, Id3 values in the grid I need to clear the combobox and edit the combobox as manually. Please advice how can I achieve this. I'm using simple list and details grid form.
 
Thanks
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 7,177 Super User 2025 Season 1 on at
    How to clear the combobox value if I move to next values in the grid
    Hi Faqru,
     
    Try to verify it again I added the same comment here.
     
    Try to move your code to the active Event handler of form data source not to the modified as you want to clear the value once  you move from record to another. Try it and tell me the result, also I think you should add your code to the init method of the form if you want it to be empty when you open the form.
     
    I noticed you declare formRun = sender.datasource().formRun(); twice remove the second one. Also are you sure weekday.clear is working? Try to set the value to the default value of the Enum. Does the enum has empty value?
     
    Thanks 
    Waed Ayyad
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to clear the combobox value if I move to next values in the grid
    Hello Waed,
     
    Its look there is technical issue in community. Once I click check box Does this answer your question? the whole page is freezed and keep loading. Could you please verify it from your end. Below reply
     
    Try to move your code to the active Event handler of form data
    source not to the modified as you want to clear the value once  you move
    from record to another. Try it and tell me the result, also I think you
    should add your code to the init method of the form if you want it to
    be empty when you open the form.
     
    I noticed you declare formRun = sender.datasource().formRun(); twice remove the second one. Also are you sure weekday.clear is working? Try to set the value to the default value of the enum. Does the enum has empty value ?
  • Waed Ayyad Profile Picture
    Waed Ayyad 7,177 Super User 2025 Season 1 on at
    How to clear the combobox value if I move to next values in the grid
    Hi Faqru,
     
    If moving the code to active method is solved your first issue. Mark it as verified answers in order to help other on the community in the future.
     
    Regards,
    Waed Ayyad
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to clear the combobox value if I move to next values in the grid
    its look there is an isse in communty to verify correct answer. The page is freeze for long time. However the below code its solved as suggested by martin.
     
    WeekDays.selection(YourEnum::None)
  • Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    How to clear the combobox value if I move to next values in the grid
    Please create a new thread for the other problem and explain it in detail there. It doesn't belong under the title "How to clear the combobox value if I move to next values in the grid".
     
    If the problem with combobox is resolved (which seems to be the case), please verify the answer.
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to clear the combobox value if I move to next values in the grid
    Thank you martin. It works. Now the combo box is empty once I select next RoutId in the grid. But I have small thing left. I have SysListPanelRelationTableCallback and records still exists of previous selection of RoutID and WeekDay. I want to be empty SysListPanelRelationTableCallback  records once I select next RoutId in the grid. Please advice.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    How to clear the combobox value if I move to next values in the grid
    The combobox is based on an enum, right? Then resettting it means setting the default value into it. For example: WeekDays.selection(YourEnum::None).
     
    By the way, the condition DAWRoutes_RouteID.valueStr() !=null doesn't make a good sense because string in X++ can't ever be null. Also, you should refer to the data source field rather than the control. Therefore you can use simply if (dawRoutes.RouteID).
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to clear the combobox value if I move to next values in the grid
    Thanks Waed. I moved my code to active() of datasource. Now its completely cleared no values found in the combo box at all to select :). I need combo box value also once I move from record to another.
     
     
        [DataSource]
        class DAWRoutes
        {
            /// <summary>
            ///
            /// </summary>
            /// <returns></returns>
            public int active()
            {
                int ret;
        
                ret = super();
                if(DAWRoutes_RouteID.valueStr() !=null)
                {
                    WeekDays.clear();
                }
        
                return ret;
            }
        }
  • Verified answer
    Waed Ayyad Profile Picture
    Waed Ayyad 7,177 Super User 2025 Season 1 on at
    How to clear the combobox value if I move to next values in the grid
    Hi Faqru,
     
    Try to move your code to the active Event handler of form data source not to the modified as you want to clear the value once  you move from record to another. Try it and tell me the result, also I think you should add your code to the init method of the form if you want it to be empty when you open the form.
     
    I noticed you declare formRun = sender.datasource().formRun(); twice remove the second one. Also are you sure weekday.clear is working? Try to set the value to the default value of the enum. Does the enum has empty value ?


    Thanks 
    Waed
     
     
     
     
     
  • Faqruddin Profile Picture
    Faqruddin 1,873 on at
    How to clear the combobox value if I move to next values in the grid
    Hello Waed,
     
    First thing the date is not placed on the grid. The date day enum is on DetailsHeader(Group) and its display weekdays  The grid contain list of data of RouteIDs. So whenever each time I select new RouteID from the gird left I need clear date enum. I follow below approach not worked. Please check my code. As you see below down when I shift to Rout-B and I need weeekdaysCombo to be empty. Currently the combo takes previous selection of Rout-A. The weekdays combo help to filters Customer available & not available data after weekday selection.
     
     
      [FormDataFieldEventHandler(formDataFieldStr(DAWCustSeq, DAWRoutes, RouteID), FormDataFieldEventType::Modified)]
        public static void RouteID_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
        {
            FormRun formRun = sender.datasource().formRun();
            DAWRoutes DAWRoutes = formRun.dataSource(formdatasourcestr(DAWCustSeq, DAWRoutes)).cursor();
            formRun = sender.datasource().formRun();
            FormComboBoxControl WeekDays = formRun.design(0).controlName("WeekDays");
            if(DAWRoutes.RouteID !=null)
                   {
                   
                   WeekDays.clear();
                   }
        }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans