1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    12
    Vote Rating
    0
    danieljamesscott is on a distinguished road

      0  

    Default Unanswered: Grid displaying many different objects

    Unanswered: Grid displaying many different objects


    I have a GXT2 project which displays database query results in a grid. The grid displays DBRow objects which extend BaseModelData. The columns within each row are stored as properties of the BaseModel and accessed using e.g. get("name") and set("name").

    The user submits a query to the DB and the results are returned. There's a DBRowHeader object which contains the information required to setup the ColumnConfig objects and the List of DBRow objects containing the data.

    In GXT3, I understand that there's the new ValueProvider which requires named properties for each model. This is no good for my use case because I would have to write a new model for each model that can be returned.

    Is there a way to implement the old system using the new GXT3 grid object?

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,640
    Answers
    107
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    Why not make a model that wraps a Map from String keys to Object values? Or, if the values are always the same type, no need to refer to them as Object. Or make the model just Map<String, Object>?

    The ValueProvider is just an interface - you can make a ValueProvider any way you want, including one that takes a string and uses that to ask the model for an object. This would act on a Map:

    Code:
    class MapValueProvider implements ValueProvider<Map<String, String>, String> {
      private final String key;
      public MapValueProvider(String key) {
        this.key = key;
      }
      public String getValue(Map<String, String> object) {
        return object.get(key);
      }
      public void setValue(Map<String, String> object, String value) {
        object.put(key, value);
      }
      public String getPath() {
        return key;
      }
    }
    This could be reused whenever you are reading data from a map. It would need to be adapted of course for a model object that wraps a map, but those changes should be clear.

    This could be used like this when making columnConfig instances:

    Code:
    new ColumnConfig<Map<String, String>, String>(new MapValueProvider("name"), ...);

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    12
    Vote Rating
    0
    danieljamesscott is on a distinguished road

      0  

    Default


    Excellent thanks. That works.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar