Search code examples
gwtgridviewextjsgwt2gxt

How to Get Textfield from Grid in GWT EXT


I have one one Grid which contain 4 column and somewhere column contain TextField and somewhere ComboBox, I achieved this by calling renderer for particular ColumnConfig. Each row is haveing one button with name "Save".

User can even make the changes to the content of textField and I want that textField content now, how to get it.

I am not able to get the enter image description heretextfield itself. When I try to get the textfield using store.getAt(0), at that time it gives me the content of TextField which was initially and not one which user modified now.

Server Code

    List<AccountResult> results = new ArrayList<AccountResult>();

for (int i = 0; i < listAccounts.size(); i++) {

Account account = listAccounts.get(i);

AccountResult accountResult=new AccountResult();
accountResult.setActionId(account.getId());
accountResult.setAccountName(account.getAccountName());
accountResult.setEmailId(account.getAccountEmail());
accountResult.setMobileNo(account.getAccountcontactNum());
accountResult.setAccountDescription(account.getAccountDesc());

results.add(accountResult);
}

Client code

ListStore<AccountResult> store = new ListStore<AccountResult>();
store.add(response.getAccountDetails());


List<ColumnConfig> configs = new ArrayList<ColumnConfig>();


ColumnConfig accountNameColumn = new ColumnConfig();
accountNameColumn.setId(AccountResult.ACCOUNT_NAME);
accountNameColumn.setHeader(Constants.VA_ACCOUNT_NAME);
accountNameColumn.setWidth(110);
accountNameColumn.setRenderer(getTextAndViewRenderer());
configs.add(accountNameColumn);

In getTextAndViewRenderer() function

accountNameTextField = getTextField(null, data, 80, Constants.VA_ACCOUNT_NAME_ID+rowIndex, Constants.VA_ACCOUNT_NAME_ID, false, false);
hp.add(accountNameTextField);

In My handleEvent for Button what should I write to get the TextField or content of it

private Listener<ButtonEvent> getActionListener(final Action action, final AccountResult result, final ListStore<AccountResult> store, final Grid<AccountResult> grid, final String property,final ColumnData config, final int rowIndex) {
return new Listener<ButtonEvent>() {


public void handleEvent(ButtonEvent be) {


}
};
}

Please help me .....Thanks


Solution

  • You're rendering TextField cell widgets, but you're missing updating your model after changing the value in your text field. Why don't you just use the default grid editing technique? http://staging.sencha.com:8080/examples-dev/#ExamplePlace:inlineeditablegrid