Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Menu and createRecordComponent

$
0
0
GWT Version
2.5.1
SmartGWT Version
4.1d (Thu Nov 07 03:18:00 GMT-800 2013)


I've been trying to implement my own custom MenuItems by using a Menu (which extends ListGrid) and implementing the following on the menu:

Code:

    final Menu addMenu = new Menu()
    {
      private final String PANEL_FIELD = "panelfield";
      {
        setShowRecordComponents(true);
        setShowRecordComponentsByCell(true);
        setShowAllRecords(true);
        setFields(getFields());
      }

      @Override
      public ListGridField[] getFields()
      {
        ListGridField panelField = new ListGridField(PANEL_FIELD, "panel");
        panelField.setCanFilter(false);
        panelField.setCanEdit(false);

        return new ListGridField[]{panelField};
      }

      @Override
      public Canvas updateRecordComponent(ListGridRecord record, Integer colNum, Canvas component, boolean recordChanged)
      {
        return component;
      }

      @Override
      public Canvas createRecordComponent(final ListGridRecord record, Integer colNum)
      {
        System.out.println("HELLO, IS THERE ANYBODY OUT THERE?");
        return new HLayout()
        {
          {
            setBackgroundColor("red");
          }
        };
      }
    };
....

List<MenuItem> data = new ArrayList<MenuItem>();
...
          for(final String type : result)
          {
            data.add(new MenuItem()
            {
              {
                setAttribute("panelfield", "hello");
                setTitle(type);
              }
            });           
          }

          addMenu.setData(data.toArray(new MenuItem[data.size()]));

The above code does not stop at all in the "createRecordComponent" method, only producing standard menu items with 'type' as the menu item title/text.

My goal is to create a menu with menu items each showing my own custom canvas that has the following:
- a large icon that is approximate 36x26px to the left
- to the right of the icon, a VLayout with two labels, top label being a 'title' and bottom label being a 'sub title/description'.

Any ideas on how to accomplish this would be appreciated.

Viewing all articles
Browse latest Browse all 4756

Trending Articles