Hello Everyone,
First of all, I am currently using Smart GWT Version “6.0p”.
What i have is a dropdown Grid that displays the reduced Data from the Datasource. (Somthing like this: http://www.smartclient.com/smartgwt/..._grid_category).
I want to add a ClickHandler, so an Action (In the Test-Code "doSomeCoolStuff") can be executed using the Clicked Record.
Also, I want the User to be able to use the Arrow Keys to navigate and execute the same Action using the "Enter" key.
So far I added a "RecordClickHandler" to the "ListGridField" and if I click the Record, I can execute a Method to work with the Record input.
But the "RecordClickHandler" also is executed when I am using the Arrow-Keys navigation through the Records.
So my Questions are:
1. Is there a RecordClickHandler, that only reacts, if the Record really is Clicked?
2. How can I Accomplish using the Accow-Keys to navigate through the List Grid and Execute an action with the currently selected Record, using the "Enter"-Key?
Test Project:
I recreated this problem within this a Test Project. Therefore, I modified the "DataSourceDMI"-Sample Code of Smartgwt, to get a good Datasource.
Also, I added the Click Handler like this: "itemField.addRecordClickHandler(event -> doSomeCoolStuff(event.getRecord()));"
In this Test Code the same behavior as described earlier can be seen:
I can reduce the Data and Click a Record to Execute the "doSomeCoolStuff" method.
Also, I can navigate through the Grid list and Execute the Command using the "Enter"-Key.
Till this point everything is what I want it to be.
But I noticed that the Handler also executed the "doSomeCoolStuff" method every time I used the Arrow Keys to navigate.
Code:
Thank you in advance!
~Jay
First of all, I am currently using Smart GWT Version “6.0p”.
What i have is a dropdown Grid that displays the reduced Data from the Datasource. (Somthing like this: http://www.smartclient.com/smartgwt/..._grid_category).
I want to add a ClickHandler, so an Action (In the Test-Code "doSomeCoolStuff") can be executed using the Clicked Record.
Also, I want the User to be able to use the Arrow Keys to navigate and execute the same Action using the "Enter" key.
So far I added a "RecordClickHandler" to the "ListGridField" and if I click the Record, I can execute a Method to work with the Record input.
But the "RecordClickHandler" also is executed when I am using the Arrow-Keys navigation through the Records.
So my Questions are:
1. Is there a RecordClickHandler, that only reacts, if the Record really is Clicked?
2. How can I Accomplish using the Accow-Keys to navigate through the List Grid and Execute an action with the currently selected Record, using the "Enter"-Key?
Test Project:
I recreated this problem within this a Test Project. Therefore, I modified the "DataSourceDMI"-Sample Code of Smartgwt, to get a good Datasource.
Also, I added the Click Handler like this: "itemField.addRecordClickHandler(event -> doSomeCoolStuff(event.getRecord()));"
In this Test Code the same behavior as described earlier can be seen:
I can reduce the Data and Click a Record to Execute the "doSomeCoolStuff" method.
Also, I can navigate through the Grid list and Execute the Command using the "Enter"-Key.
Till this point everything is what I want it to be.
But I noticed that the Handler also executed the "doSomeCoolStuff" method every time I used the Arrow Keys to navigate.
Code:
Code:
public class DataSourceDMI implements EntryPoint { public void onModuleLoad() { Layout layout = new VLayout(); layout.setHeight100(); layout.setWidth100(); DataSource supplyItemDS = DataSource.get("supplyItemDMI"); final DynamicForm form = new DynamicForm(); form.setWidth(300); ListGridField itemField = new ListGridField("itemName"); itemField.addRecordClickHandler(event -> doSomeCoolStuff(event.getRecord())); ListGridField unitsField = new ListGridField("units"); ListGridField unitCostField = new ListGridField("unitCost"); ComboBoxItem item = new ComboBoxItem("itemID"); item.setWidth(240); item.setTitle("Item"); item.setOptionDataSource(supplyItemDS); item.setValueField("SKU"); item.setDisplayField("itemName"); item.setPickListWidth(450); item.setPickListFields(itemField, unitsField, unitCostField); item.setCompleteOnTab(true); item.setShowTitle(false); item.setAutoFetchData(true); item.setMinimumSearchLength(3); item.setHideEmptyPickList(true); form.setItems(item); Layout layout = new Layout(); layout.setWidth100(); layout.setBorder("1px solid black"); layout.setHeight("5%"); layout.addMember(form); layout.draw(); } public void doSomeCoolStuff(Record record) { GWT.log("Record Clicked: " + record.getAttributeAsString("itemName")); } }
~Jay
Comment