Announcement

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

    ListGrid - Header Context Menu Column

    SmartGWT 5.0 / Firefox 26

    MenuItemClickEvent.getColNum() always returns 1 when I click on a custom header menu item on my ListGrid.

    Is there another way to determine the column number of the click?

    I also tried storing it as an attribute in the MenuItem in getHeaderContextMenuItems, but I found that this is called automatically for every column during refreshFields().

    #2
    Do you mean you've provided a customized menu via getHeaderContextMenuItems(), or something else? Did you also provide customized columns?

    Code showing more details of what you are doing would help a lot with clarifying.

    Comment


      #3
      We call:

      ListGrid.setShowHeaderMenuButton(true);

      And override:

      ListGrid.getHeaderConextMenuItems() to add custom MenuItems.

      We attached a ClickHandler to the custom MenuItems and need the column number to associate the MenuItem with that column.

      Comment


        #4
        Ah, so you are trying to figure out which field *of the ListGrid* is showing the header menu? That's passed to you in getHeaderContextMenuItems(), so you should store it at that time.

        Comment


          #5
          I do that. However I also have the requirement to update the header style based on incoming status, which calls ListGridField.setHeaderBaseStyle() followed by refreshFields() in order to update.

          refreshFields() appears to trigger getHeaderContextMenuItems() for every column, which resets my stored column index.

          Comment


            #6
            It's not clear why that call to refreshFields() is necessary (it shouldn't be needed if all you've changed is to call setHeaderBaseStyle()), but if it is needed for some reason, the simplest thing is to just set a flag before you call it, so you know not to overwrite the stored column index. There is no public API that would allow you to easily access the column index again, and all the other ways of figuring it out are much more complicated than simply avoiding the refreshFields() issue in the manner described.

            Comment


              #7
              A call to setHeaderBaseStyle() does not actually take effect until I call refreshFields(). Is there another call I can make to update it?

              Comment


                #8
                We tested whether setFieldHeaderStyle() requires a call to refreshFields() and as expected, it did not, even in the specific scenario of calling it while the header context menu is displayed.

                If you're concerned about the fact that your application seems to need this call to refreshFields(), you could try putting together a test case that shows some situation in which refreshFields() is required when it shouldn't be.

                Whether or not you try to eliminate your call to refreshFields(), you have a solution for your original question about determining the clicked field index.

                Comment

                Working...
                X