Checkbox in grid

I have a slightly odd requirement.

I have a grid that has two checkboxes in it. The second one should be disabled from editing UNLESS the first is checked. The first checkbox can be edited anytime.

I’m having a tough time doing this. I don’t know how to get a reference to this specific item (the checkbox)in the grid and even if I do I’m not sure how to set it to be uneditable alone, while the rest of the row is editable. Can anyone offer some suggestions?
Thanks

You don’t need a reference to the item, you just need to override canEditCell() to return false if the first checkbox is unchecked. You can check the first checkbox’ value via getEditedCell().

canEditCell will give me the row and Cell that’s being edited, but won’t I still need to be able to check the first checkbox to see if it’s checked?

I.E.

|Checkbox1| |Checkbox2|

//first call
canEditCell(rowNUm, colNum)
{
user checked Checkbox1. Ok.
}

canEditCell(rowNUm, colNum)
{
user is trying to check checkbox2. How can I tell that Checkbox1 has been checked for this row?
}

I suppose I could make an array of booleans to tell me which checkboxes are checked and which aren’t but that seems kind of clunky. Can I access the state of the checkbox1 of this row during the canEditCell “event?”

Use getEditedCell() to get the current value of the checkbox from some other record. As far as figuring out the rowNum of the record whose checkbox controls editability for the current record, there are APIs on ResultSet (accessible as this.data) for finding records in various ways.

Ok I’ve tried that and it seems to work fine in FF. Allows editing and denies editing just as I wanted.

Then I tried to move it over to IE and it snapped like a twig. It doesn’t throw an exception or a warning of any kind. The page builds and looks correct but when I try to click on the checkbox, particularly the second one it just doesn’t seem to pick up on it.

The state of the checkbox doesn’t change and the fields to the right of it won’t appear. If I click it repeatedly sometimes it will register and put a check in the box but whether the fields to its right will appear or will disappear when I get the check out of the box seems to be hit or miss.

I haven’t run into this problem before. The SC developer console is not flagging any errors or warnings either. It seems like the code simply is incomptaible with IE. Can anyone help me?

Requirements again:

I have a grid that has two checkboxes in it. The second one should be disabled from editing UNLESS the first is checked. The first checkbox can be edited anytime. There are four text fields after the second checkbox that can only be filled in if the second checkbox is checked (which implicitly means the first checkbox must also be checked). If a check box is unchecked, the data must be removed from subsequent fields and the subsequent fields disabled.

isc.ListGrid.create({
    ID: "SelectVersionGrid",
    name:"SelectVersionGrid",
    alternateRecordStyles: true,
    showAllRecords: true,
    canEdit: true,
    data:ProposalCustomData,
   fields: [{
   		name: "state",
        title: "State",
        editorType:"TextItem"
    }, {
   		name: "domain",
        title: "Domain",
        editorType:"TextItem"
    }, {
   		name: "pricingLead",
        title: "Pricing Lead",
        editorType:"TextItem"
    },
    {
    	name: "versionNumber",
    	title: "Version #",
    	editorType:"TextItem"
    },
    {
    	name: "versionDescription",
    	title: "Version Description",
    	editorType:"TextItem"
    },
    {
    	name: "accept",
    	title: "Accept",
    	editorType:"checkbox",
    	changed:"Accept()"
    },
    {
    	name: "collapse",
    	title: "Collapse",
    	editorType:"checkbox",
    	changed:"Collapse()"    	
    },  
    {
    	name: "burden",
    	title: "Burden",
    	editorType:"comboBox"
    },
    {
    	name: "rateGroup",
    	title: "Rate Group",
    	editorType:"comboBox"
    },    
    {
    	name: "resCode",
    	title: "Res Code",
    	editorType:"comboBox"
    },    
    {
    	name: "subRes",
    	title: "Sub Res",
    	editorType:"comboBox"
    },    
    {
    	name: "resourceDescription",
    	title: "Resource Description"
    }    
    ],
    canReorderFields: true,
    sortFieldNum: 0,
    canSort: true,
    autoDraw: false,
    autoFetchData: false,
    canEditCell:function(rowNum, colNum){
    
    //we don't care about columns before #6 so skip logic
    if(colNum < 6)
     return true;
    
    //Get relevant values
    var Record = SelectVersionGrid.getCellRecord(rowNum);
    var AcceptValue = SelectVersionGrid.getEditedCell(Record, 5);
    var CollapseValue = SelectVersionGrid.getEditedCell(Record, 6);
    
    //If Accept checkbox is checked enable Collapsed checkbox
    if( (colNum == 6) && (isFalseOrUndefined(AcceptValue) == true))
    {         
     return false;
    }
    
    //If collapsed checkbox is enabled, enable the rest of the fields
    if( (colNum > 6) &&  (colNum < 12) && (isFalseOrUndefined(CollapseValue) == true))
    {
     return false;
    }    
    
	return true;
	
    }
}); 

//utility function to see if a checkbox is true or false
function isFalseOrUndefined(value)
{
	if(value == undefined)
	{
	 return true;
	}
	 
	 if(value == false)
	  return true;
	  
	 return false;
}


//Function that fires when Accept state changes
//Basically just a way to refire canEdit after Accept becomes true
//If Accept just became false we reset all disabled fields and refire canEdit to do the disable
function Accept()
{

var Record = SelectVersionGrid.getSelectedRecord();

var AcceptValue = SelectVersionGrid.getEditedCell(Record, 5);
if(isFalseOrUndefined(AcceptValue) == true)
{
	SelectVersionGrid.setEditValues(SelectVersionGrid.getRecordIndex(Record), {"accept":false, "collapse":false, "burden":"", "rateGroup":"", "resCode":"", "subRes":"", "resourceDescription":"" });
}


SelectVersionGrid.startEditing(SelectVersionGrid.getRecordIndex(Record));

} 

//Function that fires when Collapse state changes
//Basically just a way to refire canEdit after Collapse becomes true
//If Collapse just became false we reset all disabled fields and refire canEdit to do the disable
function Collapse()
{

var Record = SelectVersionGrid.getSelectedRecord();

var CollapseValue = SelectVersionGrid.getEditedCell(Record, 6);

if(isFalseOrUndefined(CollapseValue) == true)
{
	SelectVersionGrid.setEditValues(SelectVersionGrid.getRecordIndex(Record), {"accept":true, "collapse":false, "burden":"", "rateGroup":"", "resCode":"", "subRes":"", "resourceDescription":"" });
}

SelectVersionGrid.startEditing(SelectVersionGrid.getRecordIndex(Record));

}

Well…
It seems like for some reason getEditedCell() is returning the wrong value for you in IE in your code. Seems to be a timing issue as in other tests this API seems reliable.

Easy workaround: In your changed handler actually pass the “value” parameter through to the functions that handle the change.

And we’ll take a look at what the underlying problem could be and make sure we fix it for 7.0

Thanks

Isomorphic Software

Is this fixed in 7.0 Beta.

Thanks.