Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Web Architect/Developer

    Hi,

    I use SmartGWT 4.0 with Firefox 24.8.1, I could not find a solution to set the focus in a different column in an editing row in a ListGrid after calling startEditingNew().
    The goal is to set a default value in the first column and set the focus to the second one in the current editing row.

    Code:
        private RowEditorEnterHandler rowEditorEnterHandler = new RowEditorEnterHandler() {
    		@Override
    		public void onRowEditorEnter(RowEditorEnterEvent event) {
                // getting the Row and Column of the new editing row
                ListGrid myGridList = event.
                int row = myGridList.getEditRow();
                int col = myGridList.getEditCol();
                ListGridRecord rec = myGridList.getRecord(row);
                if (rec == null) {
                    // it is a new inserted row.
                    // Setting the default name for the new added Row.
                    String defaultName = getDefaultName();
                    myGridList.setEditValue(row, col, defaultName);
                    
                    FormItem f = myGridList.getEditFormItem(0);
                    f.blurItem();
                    
                    f = myGridList.getEditFormItem(1);
                    f.focusInItem();  // <-- does not work
                    f.getForm().focusInItem(1); // <-- does not work
    
                    f.getForm().focusInNextTabElement(); //<-- throws an exception
                } 
    		}
    	};
    I even tried to set an empty string into the second column to gain the focus but was not successful. I don't know what am I missing. A solution or workaround would be appreciated.

    #2
    Call startEditing() passing rowNum and colNum of where you want editing to move to.

    You should update to 5.0 as soon as possible (or at the very least, 4.1).

    Comment


      #3
      Thanks for quick response I trieed the startEditing(int, int) immediately after setting the value,, did not work.

      I will upgarde to 5.0 and test it again

      Code:
      		int row = setListGrid.getEditRow();
      		int col = setListGrid.getEditCol();
      		ListGridRecord rec = setListGrid.getRecord(row);
      		
      		if (rec == null) {
      			// it is a new inserted row.
      			// Setting the default name for the new added Row.
      			String defaultName = getDefaultName();
      			setListGrid.setEditValue(row, col, defaultName);
      			setListGrid.startEditing(row, col + 1);
      		}
      Thanks

      Comment

      Working...
      X