views:

725

answers:

1

We're using SmartClient GWT library (see the Smartclient GWT showcase here).

I'm trying to make a ListGrid UI that when you click a record the fields become editable. Just like the example:

The difference is I'm using my own custom GWT RPC services and manually adding ListGridRecord's to my own DataSource, and I see my records appear but the fields aren't editable when clicked. I've created a custom DataSource using the GWTRPCDataSource implementation and properly override the executeFetch method.

Is there some special processing that's going on using the examples XML DataSource that creates ListGridRecords that properly set it up to be editable?

For example I'm using the CountryXMLDS.java just like the example except I'm adding one custom record (and I've removed all fields but the population field that I want to be editable). I see my record appear but the field is NOT editable when the record is clicked.

    ListGridField populationField = new ListGridField("population", "population");
    populationField.setType(ListGridFieldType.INTEGER);
    populationField.setCanEdit(true);

   countryGrid.setFields( populationField);

    countryGrid.setCanEdit(true);
    countryGrid.setEditEvent(ListGridEditEvent.CLICK);


    ListGridRecord record = new ListGridRecord();
    record.setAttribute("population", "5");
    CountryXmlDS.getInstance().addData(record);
+1  A: 

Whatever the problem is, it's not in the details you've shared. Try these steps:

  1. make sure you're calling setDataSource() on the ListGrid with your DataSource

  2. make sure the name of your ListGrid field matches a field from the DataSource. This is case sensitive

  3. make sure you have a primaryKey declared in the DataSource. There's no way to save edits unless there's a way to identify records

  4. look for messages in the Developer Console

    http://forums.smartclient.com/showthread.php?t=8159#aConsole

  5. shotgun approach: override ListGrid.canEditCell() and return whatever you want - this overrides all the declarative settings like field.canEdit.

Charles Kendrick
Setting the primaryKey seemed to be the issue.
Dougnukem