Hello, I can't handle with such an easy operation :-(
I'm using smartgwt 4.1
I need to create a grid with three columns.
In the first and the second column I need to keep Id and lable of an entity from database. I want to receive this data by Request.
In the third row I want to keep a ListBox with 3 options - "no","R","RW"
I'm trying to do it this way:
it shows me a grid with a listbox. But when I change selections in two rows and try to iterate grid to get this rows - i get only first value.
Guys, I can't understand what I'm doing wrong. Please, help me with this rather easy task
I'm using smartgwt 4.1
I need to create a grid with three columns.
In the first and the second column I need to keep Id and lable of an entity from database. I want to receive this data by Request.
In the third row I want to keep a ListBox with 3 options - "no","R","RW"
I'm trying to do it this way:
Code:
ListGrid rightsGrid = new ListGrid(); .... ListGridField rdsUnique = new ListGridField("uniqueId", "uniqueId"); rdsUnique.setHidden(true); ListGridField rdsLabel = new ListGridField("label", rolesDirNLS.objectName()); rdsLabel.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH); rdsLabel.setCanEdit(false); ListGridField rdsRight = new ListGridField("right", rolesDirNLS.right()); ResultSet resultSet = new ResultSet(); rightsGrid.setShowAllRecords(true); rightsGrid.setAlwaysShowEditors(true); rightsGrid.setFields(rdsUnique, rdsLabel, rdsRight); rdsRight.setAutoFitWidthApproach(AutoFitWidthApproach.TITLE); rightsGrid.setCanEdit(true); rightsGrid.setEditEvent(ListGridEditEvent.CLICK); SelectItem rightSelectItem = new SelectItem(); rightSelectItem.setValueMap("NO", "R", "RW"); rightSelectItem.setEmptyDisplayValue(rolesDirNLS.no()); rightSelectItem.setDefaultValue(rolesDirNLS.no()); rightSelectItem.setAddUnknownValues(false); rdsRight.setEditorType(rightSelectItem); RequestBuilder getObjects = new CustomRequestBuilder(RequestBuilder.GET, common.prefix() + "/object_type/"); getObjects.setCallback(new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { JSONArray objectsArray = JSONParser.parseStrict(response.getText()).isArray(); for (int i = 0; i < objectsArray.size(); i++) { JSONObject Object = objectsArray.get(i).isObject(); if (Object != null) { ListGridRecord record = new ListGridRecord(); record.setAttribute("uniqueId", Object.get("uniqueId").isString().stringValue()); record.setAttribute("label", Object.get("label").isString().stringValue()); rightsGrid.addData(record); } } } else { SC.warn(notifications.rest_on_error()); } } @Override public void onError(Request request, Throwable throwable) { SC.warn(throwable.getMessage()); } }); try { getObjects.send(); } catch (RequestException e) { e.printStackTrace(); }
Guys, I can't understand what I'm doing wrong. Please, help me with this rather easy task
Comment