Announcement

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

    Inconsistent ListGrid selection behavior

    I'm using the June 4 nightly build. I have a ListGrid with a view only field and a conditionally editable field. I'm also using SelectionAppearance.CHECKBOX and I want the user to be able to select multiple rows. The problem is, when I click on a field where the conditionally editable field is editable, it de-selects other rows that have already been selected. If I click on a row where the conditionally editable field is NOT editable I'm able to select multiple rows.

    Here is my grid setup code ...
    Code:
    conditionsGrid = new ListGrid() {
    	@Override
    	protected boolean canEditCell(int rowNum, int colNum) {
    		ListGridRecord record = conditionsGrid.getRecord(rowNum);
    		return record.getAttributeAsBoolean("CaptureValue");
    	}
    };
    conditionsGrid.setDataSource(termsAndConditionsDS);
    conditionsGrid.setWrapCells(true);
    conditionsGrid.setEditEvent(ListGridEditEvent.CLICK);
    conditionsGrid.setCanEdit(true);
    conditionsGrid.setFixedRecordHeights(false);
    conditionsGrid.setAutoFetchData(true);
    conditionsGrid.setShowHeader(false);
    ListGridField groupField = new ListGridField("Group");
    ListGridField descriptionField = new ListGridField("Description");
    descriptionField.setWidth("80%");
    descriptionField.setCanEdit(false);
    ListGridField valueField = new ListGridField("Value");
    ListGridField captureValueField = new ListGridField("CaptureValue");
    captureValueField.setHidden(true);
    valueField.setType(ListGridFieldType.TEXT);
    valueField.setWidth("20%");
    groupField.setHidden(true);
    conditionsGrid.setFields(
    		groupField,
    		descriptionField,
    		valueField
    );
    conditionsGrid.setGroupByField("Group");
    conditionsGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
    conditionsGrid.setGroupStartOpen(GroupStartOpen.ALL);
    conditionsGrid.setWidth100();
    conditionsGrid.setAutoFitData(Autofit.VERTICAL);
    conditionsGrid.setSelectOnEdit(true);
    Here is the data source ...
    Code:
    <DataSource ID="TermsAndConditions"
    	clientOnly="true"
        testFileName="/ds/test_data/TermsAndConditions.data.xml">
        <fields>
    		<field name="id" title="id" type="sequence" hidden="true" primaryKey="true"/>
    		<field name="Group" title="Group" type="text" length="60"/>
    		<field name="Description" title="Description" length="256"/>
    		<field name="CaptureValue" title="Capture value?" type="boolean" detail="true"/>
    		<field name="Value" title="Value" type="text" length="20"/>
    	</fields>
    </DataSource>
    And here is my test data ...
    Code:
    <List>
    
    	<TermsAndConditions>
    		<id>1</id>
    		<Group>Domestic</Group>
    		<Description>We reserve the right to take 2%-10 Days, 3% Warehousing
    		</Description>
    		<CaptureValue>false</CaptureValue>
    	</TermsAndConditions>
    
    	<TermsAndConditions>
    		<id>2</id>
    		<Group>Domestic</Group>
    		<Description>All Shipments are F.O.B., Designated Locations
    		</Description>
    		<CaptureValue>false</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>3</id>
    		<Group>Domestic</Group>
    		<Description>This Order is subject to pre-production and production
    			sample approval</Description>
    		<CaptureValue>false</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>4</id>
    		<Group>Domestic</Group>
    		<Description>Fax shipping confirmation to YM Inc. (Sales) Import Dept:
    			416-789-8983</Description>
    		<CaptureValue>false</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>5</id>
    		<Group>Domestic</Group>
    		<Description>Freight To:</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>6</id>
    		<Group>Domestic</Group>
    		<Description>Will be paid by:</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>7</id>
    		<Group>Import</Group>
    		<Description>F.O.B $ USA</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>8</id>
    		<Group>Import</Group>
    		<Description>F.O.B $ CDN</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>9</id>
    		<Group>Import</Group>
    		<Description>USA Quota CAT. &amp; Cost</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>10</id>
    		<Group>Import</Group>
    		<Description>C.N.F $ USA</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>11</id>
    		<Group>Import</Group>
    		<Description>C.N.F $ CDN</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>12</id>
    		<Group>Import</Group>
    		<Description>NET ROG</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>13</id>
    		<Group>Import</Group>
    		<Description>CDN DUTY</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    	<TermsAndConditions>
    		<id>14</id>
    		<Group>Import</Group>
    		<Description>USA DUTY</Description>
    		<CaptureValue>true</CaptureValue>
    	</TermsAndConditions>
    </List>

    #2
    Looking into this..

    Comment


      #3
      Hi Jay,
      This is to do with the 'selectOnEdit' property. For now you can call 'setSelectOnEdit(false)' and when you start editing a field it won't update the selection at all.

      We've also made a change in mainline so that when selectOnEdit is true (the default), and we're doing "simple" type selection as we do when selectionAppearance is checkbox, we will still select the edit row when the user starts editing it, but without deselecting the other rows. This change will show up in nightlies from now on.

      Thanks
      Isomorphic Software

      Comment


        #4
        Thanks. setSelectOnEdit(false) works for me in this case.

        One related item for the wish list ... I need to add to my canEditCell logic so that the cell is editable only if the ListGrid row is selected. There doesn't seem to be a simple way to tell if a particular row is selected. You have to iterate over the ListGrid.getSelection() and look for a row with an ID that matches the rowNum of the cell in question. A simple helper method like ListGrid.isSelected(rowNum) or ListGridRecord.isSelected() would be helpful.

        Thanks again for your terrific support!

        Comment

        Working...
        X