web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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,883
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
I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    Which version of AX are you using? I'm assuming it's either AX 2012, or you actually mean D365FO and asking in the AX forum by mistake?
     
    Is the combo box bound to a data source field? If so, is it the same data source as in the grid? If so, you're getting the value that you have stored in database. Are you saying that you want to ignore the current data and always set a fixed value?
     
    What do you mean by "edit as manually"?
  • Faqruddin Profile Picture
    1,883 on at
    The version D365 Fo. The combo box is not bound to the datasource field. I added the controler called weekdays and set the enumtype weekdays. In the form actual datasource it already holds the field called day and it has data from external sources. I wrote excutequey() and selectionchanged() method to filter. But here as I said above once I move id2, id3 I need combobox to be empty and allow to be editable and clear previous selections.
  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi Faqru,
    Do you want to filter date of the grid based on the enum?
    Do you clear its value every time you open the Form?
    If yes, try to clear it on the init of the form.
     
  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi Faqru,

    Do you want to filter date of the grid based on the enum?

    Do you want clear its value every time you open the Form?

    If yes, try to clear it on the init method of the form.

     
  • Faqruddin Profile Picture
    1,883 on at
    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();
                   }
        }
  • Verified answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    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
    1,883 on at
    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
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    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
    1,883 on at
    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.
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans