Announcement

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

    ListGrid items are disabled... until a new one is added

    Hello SmartGWT Friends.

    I have a very strange thing going on. Throughout my app i use various ListGrid, which have myGrid.setCanEdit(true); and this all works (obviously :-) ).

    One of them, though, is disabled (but shows the fetch data correctly!). It is a very very simple .ds.xml file and I just do not see what the problem is.

    If I add a new record using a form that is displayed below the grid, that PARTICULAR new record IS ENABLED.

    So why do I get the grid to be disabled? Must be something stupid probably... but still. Below is my code. It really is very simple.

    Please look at the UserManagementWindow#initUserGrid() method to see how I initiated the grid. Any ideas why this happens?.

    users.ds.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <DataSource ID="users" serverType="sql" tableName="users"> 
      <fields> 
        <field name="username" type="text" length="50" primaryKey="true" required="true" />
        <field name="email" type="text" required="true"/>  
        <field name="password" type="text" length="50"/>  
        <field name="salt" type="hidden"/>  
        <field name="enabled" type="boolean" required="false"/>  
      </fields>  
    </DataSource>

    The view for showing the users.
    Code:
    public class UserManagementWindow extends Window {
    
    	ListGrid users = new ListGrid();
    	DataSource usersDataSource = DataSource.get("users");
    	VLayout panel = new VLayout();
    
    	DynamicForm userForm = new DynamicForm();
    
    	public UserManagementWindow() {
    		setShowModalMask(true);
    		setModalMaskOpacity(100);
    		centerInPage();
    		this.setWidth("80%");
    		this.setHeight("80%");
    		setShowCloseButton(true);
    		setShowMinimizeButton(false);
    		setIsModal(true);
    		setAutoCenter(true);
    		setAutoSize(true);
    		setTitle("User Management");
    
    		panel.setAutoHeight();
    		panel.setWidth100();
    		panel.setHeight100();
    
    		initUsersGrid();
    		initNewUserForm();
    
    		panel.addMember(users);
    		panel.addMember(userForm);
    
    		this.addItem(panel);
    	}
    
    	public void initUsersGrid() {
    		users.setAlternateRecordStyles(true);
    		users.setCellHeight(22);
    		users.setDataSource(usersDataSource);
    		users.setAutoFetchData(false);
    		users.setCanEdit(true);
    		users.setEditEvent(ListGridEditEvent.DOUBLECLICK);
    
    		
    		users.setModalEditing(true);
    		users.setShowFilterEditor(true);
    		users.setDoubleClickDelay(100);
    		users.setListEndEditAction(RowEndEditAction.NEXT);
    		users.setCanRemoveRecords(true);
    		users.setAutoSaveEdits(true);
    		users.setWidth100();
    		users.setHeight(200);
    
    		ListGridField userNameField = new ListGridField("username", "Gebruiker");
    		
    
    		ListGridField enabledField = new ListGridField("enabled",
    				"Account actief");
    
    		users.setFields(userNameField, enabledField);
    		users.fetchData();
    	}
    
    	public void initNewUserForm() {
    		userForm.setDataSource(usersDataSource);
    
    		TextItem username = new TextItem("username", "Username");
    		TextItem email = new TextItem("email", "Email");
    
    		SelectItem t = new SelectItem("thegroups", "Groepen");
    		t.setMultiple(true);
    		t.setMultipleAppearance(MultipleAppearance.PICKLIST);
    		DataSource gd = DataSource.get("groups_table");
    		t.setOptionDataSource(gd);
    		t.setValueField("group_name");
    		t.setDisplayField("group_name");
    
    		ButtonItem submit = new ButtonItem("submit", "Gebruiker aanmaken");
    		submit
    				.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
    					public void onClick(
    							com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
    						userForm.saveData();
    					}
    				});
    		userForm.setFields(username, email, t, submit);
    
    	}
    
    }

    #2
    Pfah looking at this for days now, I just don't see why this is happening.


    Anyone? :(

    Comment


      #3
      Can you explain a bit more what you want the behavior to be? When the user tries to create a new record what do you expect to happen? The record is not created at all or it is disabled automatically? I can't run your code at the moment to see what behavior you are talking about so not sure what you mean the record is enabled.

      Comment


        #4
        It is just supposed to be a listgrid whose records are editable by double clicking on one of its entries (ie. in-line editable).

        Also, i've made a form below it, to add a new record.

        And the whole data operation stuff works, as in, it shows the data correctly, and I can add new data using the form submit.

        see the screenshot I've attached. The buttons are in Dutch, but just know that the fetch/add operations work, whereas doubleclicking a record (ie. the update operation) in the grid doesn't. Also, the delete button cannot be clicked. You can see that the texts in the grid are grey, but the grid is sortable/filterable.

        It is strange in the sense that tons of other ListGrids throughout my app have the same configuration, yet they work. (except if i'm missing something)
        Attached Files
        Last edited by Kah0ona; 13 Oct 2010, 08:51.

        Comment


          #5
          Have you just tried calling enable() on it? From your code nothing to disable it but would have to see everything else to get at why that is the case.

          Comment


            #6
            yes, I tried that.

            Does it have something to do that it is in a Window? The window pops up if you press a button in my application.

            Comment


              #7
              Shouldn't affect it. It looks like the form is obviously ok. Anything printing in the developer console?

              Comment


                #8
                *** EDIT: next post shows what the developer console is printing ***

                Tomorrow I try to run the window on a standalone project (timezone = CET here, so getting quite late), and see what's what.

                Is there anything known which can cause such a thing? Is it to be found on the serverside? .ds.xml side? Or client-side?

                ps. this code starts the window, so really there seems not to be a chance where I could have called disable() on it. Also, if disable() is called, the headers are also not clickable (that is the filter/sorting is not clickable. In my case it is).

                Code:
                ... method inside some widget that extends Toolstrip
                
                Button userManagementButton = new Button("User management");
                
                /**
                * Adds the User Management button to the toolbar
                */
                public void addUserManagementButton() {
                	userManagementButton.addClickHandler(new ClickHandler() {
                		public void onClick(ClickEvent event) {
                			UserManagementWindow u = new UserManagementWindow();
                			u.show();
                			u.bringToFront();
                
                		}
                	});
                	userManagementButton.hide(); //show when clicked, hide for now...
                	addMember(userManagementButton);
                }
                Last edited by Kah0ona; 14 Oct 2010, 00:10.

                Comment


                  #9
                  When I start up the Window, as with the button from the previous post, my developer console says the following (log level INFO).

                  Code:
                  09:53:01.279:XRP0:INFO:RPCManager:transaction 25 arrived after 14009ms
                  09:53:01.281:XRP0:INFO:RPCManager:rpcResponse(getGroupsForTheSelectedUser)[fetch]: result: 13 records[status=0]
                  09:53:01.281:XRP0:INFO:xmlBinding:users:dsResponse is: {operationId: "getGroupsForTheSelectedUser",
                  clientContext: Obj,
                  context: Obj,
                  transactionNum: 25,
                  httpResponseCode: 200,
                  httpResponseText: "//isc_RPCResponseStart-->[{endRow:13,tot..."[1850],
                  xmlHttpRequest: [object XMLHttpRequest],
                  transport: "xmlHttpRequest",
                  status: 0,
                  clientOnly: undef,
                  httpHeaders: Obj,
                  isStructured: true,
                  callbackArgs: null,
                  results: Obj,
                  endRow: 13,
                  totalRows: 13,
                  isDSResponse: true,
                  invalidateCache: false,
                  startRow: 0,
                  data: Array[13]}
                  09:53:01.282:XRP0:INFO:ResultSet:isc_ResultSet_20 (created by: isc_ListGrid_19):Received 13 records from server
                  09:53:01.282:XRP0:INFO:ResultSet:isc_ResultSet_20 (created by: isc_ListGrid_19):cached 13 rows, from 0 to 13 (13 total rows, 13 cached)
                  09:53:01.282:XRP0:INFO:ResultSet:isc_ResultSet_20 (created by: isc_ListGrid_19):Cache for entire DataSource complete
                  09:53:01.283:XRP0:INFO:redraws:isc_ListGrid_19_body:Scheduling redraw (dataChanged)
                  09:53:01.283:XRP0:INFO:clears:isc_globalPrompt:clear() (2 children) 
                  09:53:01.291:XRP0:INFO:clickMask:hideClickMask called with ID: isc_globalPrompt
                  09:53:01.291:XRP0:INFO:clickMask:hiding clickMask ID: isc_globalPrompt[autoHide:false] with index: 1 of 1
                  09:53:05.024:RDQ3:INFO:recordComponentPool:isc_ListGrid_19:
                  _drawAreaChanged: drawArea details: 
                  oldDrawArea: 0,0,0,0
                  newDrawArea: 0,12,0,3
                  removeArea: 0,0,0,0
                  addArea: 0,12,0,3
                  
                  09:53:05.024:RDQ3:INFO:recordComponentPool:isc_ListGrid_19:
                  _drawAreaChanged: Before processing: 
                  grid.$74m has 0 entries
                  body.$29a has 0 entries
                  
                  09:53:05.025:RDQ3:INFO:recordComponentPool:isc_ListGrid_19:
                  _drawAreaChanged: After removals: 
                  grid.$74m has 0 entries
                  body.$29a has 0 entries
                  
                  09:53:05.025:RDQ3:INFO:recordComponentPool:isc_ListGrid_19:
                  _drawAreaChanged: After additions: 
                  grid.$74m has 0 entries
                  body.$29a has 0 entries
                  
                  09:53:05.028:RDQ3:INFO:drawing:isc_ListGrid_19_body:$ra(): redrawing
                  09:53:05.407:RDQ3:INFO:sizing:isc_ListGrid_19_body:Specified size: 1011x153, drawn scroll size: 1011x286, border: 0x0, margin: 0x0, reason: redraw
                  09:53:05.413:RDQ3:INFO:scrolling:isc_ListGrid_19_body:Drawn size: 995 by 286, specified: 1011 by 153, scrollbar state: v
                  09:53:05.413:RDQ3:INFO:scrolling:isc_ListGrid_19_body:Scrollbar state:  -> V
                  09:53:05.429:RDQ3:INFO:draws:isc_ListGrid_19_body_vscroll:draw(): drawing Scrollbar with parent:[ListGrid ID:isc_ListGrid_19]
                  09:53:05.432:RDQ3:INFO:drawing:isc_ListGrid_19_body_vscroll:inserting HTML next to master element: [GridBody ID:isc_ListGrid_19_body]
                  09:53:05.434:RDQ3:INFO:sizing:isc_ListGrid_19_body_vscroll:Specified size: 16x153, drawn scroll size: 16x153, border: 0x0, margin: 0x0, reason: draw
                  09:53:05.435:RDQ3:INFO:drawing:isc_ListGrid_19_body_vscroll:drawPeers(): 1 peers
                  09:53:05.436:RDQ3:INFO:draws:isc_ListGrid_19_body_vscroll_thumb:draw(): drawing VScrollThumb with parent:[ListGrid ID:isc_ListGrid_19]
                  09:53:05.438:RDQ3:INFO:draws:isc_ListGrid_19_body_vscroll_thumb_label:draw(): drawing Label with parent:[ListGrid ID:isc_ListGrid_19]
                  09:53:05.440:RDQ3:INFO:drawing:isc_ListGrid_19_body_vscroll_thumb_label:inserting HTML into parent:[ListGrid ID:isc_ListGrid_19]
                  09:53:05.442:RDQ3:INFO:sizing:isc_ListGrid_19_body_vscroll_thumb_label:Specified size: 16x65, drawn scroll size: 16x65, border: 0x0, margin: 0x0, reason: draw
                  09:53:05.444:RDQ3:INFO:drawing:isc_ListGrid_19_body_vscroll_thumb:inserting HTML next to master element: [Scrollbar ID:isc_ListGrid_19_body_vscroll]
                  09:53:05.446:RDQ3:INFO:sizing:isc_ListGrid_19_body_vscroll_thumb:Specified size: 16x65, drawn scroll size: 16x65, border: 0x0, margin: 0x0, reason: draw
                  09:53:05.446:RDQ3:INFO:drawing:isc_ListGrid_19_body_vscroll_thumb:drawPeers(): 1 peers
                  09:53:05.449:RDQ3:INFO:drawing:isc_ListGrid_19_body:redrawPeers(): 1 peers
                  09:53:09.185:TMR5:INFO:sizing:isc_ListGrid_19:Specified size: 1013x200, drawn scroll size: 1011x176, border: 2x2, margin: 22x0, reason: childDraw
                  And when I 'eval JS' the isc_ListGrid_19 object, i get the following:
                  Code:
                  Evaluator: result of 'isc_ListGrid_19...' (0ms):
                  ListGrid{ID: "isc_ListGrid_19",
                  redrawOnResize: false,
                  modalEditing: true,
                  alternateRecordStyles: true,
                  dataSource: [DataSource ID:users],
                  autoFetchData: true,
                  canEdit: true,
                  fetchOperation: "getGroupsForTheSelectedUser",
                  showFilterEditor: true,
                  doubleClickDelay: 100,
                  listEndEditAction: "next",
                  canRemoveRecords: true,
                  width: 1013,
                  height: 200,
                  fields: Array[4],
                  position: "absolute",
                  className: "listGrid",
                  data: [ResultSet ID:isc_ResultSet_20 (created by: isc_ListGrid_19)],
                  selectionType: "multiple",
                  showResizeBar: false,
                  parentElement: [VLayout ID:isc_VLayout_3],
                  topElement: [Window ID:isc_UserManagementWindow_2],
                  tabIndex: 4252,
                  booleanTrueImage: "[SKINIMG]/DynamicForm/checked.png",
                  booleanFalseImage: "[SKINIMG]/DynamicForm/unchecked.png",
                  booleanPartialImage: "[SKINIMG]/DynamicForm/partialcheck.png",
                  booleanImageWidth: 13,
                  booleanImageHeight: 13,
                  originalFields: Array[0],
                  completeFields: Array[4],
                  canFreezeFields: true,
                  header: [Toolbar ID:isc_Toolbar_3],
                  sorter: [ImgButton ID:isc_ListGrid_19_sorter],
                  children: Array[7],
                  headers: Array[1],
                  filterEditor: [RecordEditor ID:isc_ListGrid_19filterEditor],
                  peers: Array[1],
                  zIndex: 202880,
                  body: [GridBody ID:isc_ListGrid_19_body],
                  bodies: Array[1],
                  dragScrollTarget: [GridBody ID:isc_ListGrid_19_body],
                  selection: [Selection ID:isc_ListGrid_19_selection],
                  innerWidth: 995,
                  bodyHeight: 153,
                  bodyWidth: 1011,
                  }
                  I don't see anything peculiar, but you might, as you are more experienced with the dev console's output.
                  Last edited by Kah0ona; 14 Oct 2010, 00:00.

                  Comment


                    #10
                    Okay, and the strange thing is, when I add a new record using the form, that particular one CAN be selected (see attached screenshot).

                    On that point, if I do a 'eval JS' on the object, the object looks as follows.

                    Code:
                    Evaluator: result of 'isc_ListGrid_19...' (0ms):
                    ListGrid{ID: "isc_ListGrid_19",
                    redrawOnResize: false,
                    modalEditing: true,
                    alternateRecordStyles: true,
                    dataSource: [DataSource ID:users],
                    autoFetchData: true,
                    canEdit: true,
                    fetchOperation: "getGroupsForTheSelectedUser",
                    showFilterEditor: true,
                    doubleClickDelay: 100,
                    listEndEditAction: "next",
                    canRemoveRecords: true,
                    width: 1013,
                    height: 200,
                    fields: Array[4],
                    position: "absolute",
                    className: "listGrid",
                    data: [ResultSet ID:isc_ResultSet_20 (created by: isc_ListGrid_19)],
                    selectionType: "multiple",
                    showResizeBar: false,
                    parentElement: [VLayout ID:isc_VLayout_3],
                    topElement: [Window ID:isc_UserManagementWindow_2],
                    tabIndex: 4252,
                    booleanTrueImage: "[SKINIMG]/DynamicForm/checked.png",
                    booleanFalseImage: "[SKINIMG]/DynamicForm/unchecked.png",
                    booleanPartialImage: "[SKINIMG]/DynamicForm/partialcheck.png",
                    booleanImageWidth: 13,
                    booleanImageHeight: 13,
                    originalFields: Array[0],
                    completeFields: Array[4],
                    canFreezeFields: true,
                    header: [Toolbar ID:isc_Toolbar_3],
                    sorter: [ImgButton ID:isc_ListGrid_19_sorter],
                    children: Array[7],
                    headers: Array[1],
                    filterEditor: [RecordEditor ID:isc_ListGrid_19filterEditor],
                    peers: Array[1],
                    zIndex: 202880,
                    body: [GridBody ID:isc_ListGrid_19_body],
                    bodies: Array[1],
                    dragScrollTarget: [GridBody ID:isc_ListGrid_19_body],
                    selection: [Selection ID:isc_ListGrid_19_selection],
                    innerWidth: 995,
                    bodyHeight: 153,
                    bodyWidth: 1011,
                    headerMenuButton: [HeaderImgButton ID:isc_ListGrid_19_headerMenuButton],
                    }
                    Attached Files

                    Comment


                      #11
                      I just tried something I hadn't before:
                      If i change the datasource to a random other one from my application, ie.:

                      Code:
                      users.setDataSource(DataSource.get("SomeOtherDs"));
                      It IS editable!

                      Weird ... but good to know nonetheless. I'm off searching again.

                      Comment


                        #12
                        SOLVED!

                        Well, I found the problem, and this might be a bug.

                        This was my users.ds.xml:
                        Code:
                        <DataSource ID="users" serverType="sql" tableName="users"> 
                          <fields> 
                            <field name="username" type="text" length="50" primaryKey="true" required="true"> 
                            </field>  
                            <field name="email" type="text" required="true"/>  
                            <field name="password" type="text" length="50"/>  
                             <field name="salt" type="hidden"/>  
                             <field name="enabled" type="boolean" required="false"/> 
                        </DataSource
                        If the field is called 'enabled', it doesn't work. If it is however called 'enabled2' or that is, something different, it works.

                        It seems that name='enabled' is some sort of a keyword, which explains the fact that the grid was not enabled.

                        I will change the columnname in the database, and I can continue. Thanks.

                        Comment


                          #13
                          See ListGrid.setRecordEnabledProperty

                          Edit : I see the javadocs mention the default being "_enabled" instead of "enabled". We'll either fix the javadoc or change the default recordEnabledProperty to "_enabled".
                          Last edited by smartgwt.dev; 14 Oct 2010, 07:23.

                          Comment


                            #14
                            Aha, i wasn't aware of that. Thanks for the help.

                            Comment

                            Working...
                            X