Easy way to prevent a user from unchecking a checkbox in a datagrid

Hi i have a checkbox datagridcolumn inside a datagrid, how can i prevent user from unchecking the checkbox located in first row without creating a whole itemrenderer etc..

//someArray is bindable

<mx:DataGrid  id="somegrid" dataProvider="{someArray}" >
  <mx:columns>
    ....etc...
        <mx:DataGridColumn dataField="isChecked" rendererIsEditor="true" editorDataField="selected" >
               <mx:itemRenderer>
	<fx:Component>
	      <mx:CheckBox   click="outerDocument.displayCheckBox_clickHandler()" />  
                   </fx:Component>
               </mx:itemRenderer>
        </mx:DataGridColumn>	
</mx:columns>
</mx:DataGrid>

public function displayCheckBox_clickHandler():void
{
        if(somegrid.selectedIndex==0)
       {
              // set the filterArray[0].isChecked = true
              // basically check the checkbox again, but this does NOT work, the filterArray[0].isChecked is set to false again.
             // i think due to the way the events are ran.  
             //This is my question, how do you prevent a user from unchecking the checkbox in first row of the datagrid
            //OR  to auto recheck it after they uncheck it.        
      }
}

Open in new window

LVL 1
gagaliyaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ron MalmsteadInformation Services ManagerCommented:
Checkbox1.enabled = false

It will still be visible...but clicking on it will do nothing.
0
dgofmanCommented:
I cannnot understand an answer from xuserx2000

So, my solution is

<fx:Script>
	<![CDATA[
		[Bindable]
		private var someArray:Array = [{isChecked:1},{isChecked:2},{isChecked:3}];
	]]>
</fx:Script>
<mx:DataGrid  id="somegrid" dataProvider="{someArray}" >
	<mx:columns>
		<mx:DataGridColumn dataField="isChecked">
			<mx:itemRenderer>
				<fx:Component>
					<mx:CheckBox>
						<fx:Script>
							<![CDATA[
								override public function get selected():Boolean{
									return (listData && listData.rowIndex == 0 ? true : super.selected);
								}
							]]>
						</fx:Script>
					</mx:CheckBox>  
				</fx:Component>
			</mx:itemRenderer>
		</mx:DataGridColumn>	
	</mx:columns>
</mx:DataGrid>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gagaliyaAuthor Commented:
Thanks that's exactly what I was looking for.

Not quite sure what xuserx2000 was talking about either.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Flex

From novice to tech pro — start learning today.