2

I have a grid, and ValueProviders releated to this grid. If I want to add ValueProviders to the column one by one as ColumnConfig's, then it's OK. I mean I can add the columns like Name - Surname - Adress etc.

But now, I have a different case. I must add some fields like Name / Surname - Adress / Mail - Phone Number etc. In short, I need to merge ValueProviders' values. How can I merge them? Or is it possible in another way? I'm looking for a solution from annotations. A code snippet from my properties file.

@Path("bolum.ad")
    ValueProvider<Deneme, String> bolumAd();
@Path("bolum.aciklama")
    ValueProvider<Deneme, String> bolumAciklama();

I'm using GXT 3.0

Thanks.

Uğurcan Şengit
  • 976
  • 1
  • 11
  • 31
  • Can you clarify what you mean by merging values? For example, if getName() and getSurname() both return null, would you expect them to output "NameSurname", or some other way of dividing them? – Colin Alworth Oct 01 '13 at 11:41
  • Assuming that name and surname values are "Ugurcan" and "Sengit", I need to append them like "Ugurcan / Sengit". If the value is null, it will probably become "null / null". – Uğurcan Şengit Oct 01 '13 at 11:43

1 Answers1

3

In my suggestion, you can create a new value provider to facilitate this. Here is an example:

ValueProvider<Deneme, String> customValueProvider = new ValueProvider<Deneme, String>() {

            @Override
            public void setValue(Deneme object, String value) {
            }

            @Override
            public String getValue(Deneme item) {
                return item.name() + "/" + item.surname();
            }

            @Override
            public String getPath() {
                return null;
            }
        };

Then you can use the customValueProvider in your code, instead of using direct Value Provider.

  • In the process, if you use a null check, like the following: `... (item.name() == null ? "" : item.name()) + ...` The grid column won't show null values. – Roohul Poolak Oct 01 '13 at 12:16