Hi,
I have Editable Grid. In that there are some editable columns. In some rows, I want this column should behave as readonly. How can we conditionally control editable behavior of a grid column.
Thanks,
Vinay
You can achieve this behaviour of the grid by simply adding some JavaScript to your page. I have slightly changed one of our examples on WebGrid (Cell Editing - Client Events) so that the enteringEditMode event is canceled under some conditions.
In JSF:
<f:view>
<h:form>
<f:verbatim escape="false">
<br />
<textarea id="eventDumps" cols="60" rows="10"></textarea>
<br>
<input type="button" value="Clear"
onclick="document.getElementById('eventDumps').innerHTML='';"/>
<script type="text/javascript" >
function EventHandler(sender, args, eventType){
if(!sender) return;
var outStr = "Source: " + cell.getGrid().getId + "[" + cell.getIndex() + ", " + cell.getRowIndex() + "] EventType: " + eventType;
el.scrollTop = el.scrollHeight - el.clientHeight;
}
var cell = args.getCell();
else{
function ExitedEditMode(sender, args){
</script>
</f:verbatim>
<ig:gridView dataSource="#{cancelEvent.list}" pageSize="10">
<ig:gridActivation></ig:gridActivation>
<ig:gridEditing enableOnMouseClick="double" enableOnActive="false"
enableOnKeyPress="true" enableOnF2="true" editMode="cell"
updateMode="row"></ig:gridEditing>
<ig:gridClientEvents enteringEditMode="EnteringEditMode"
enteredEditMode="EnteredEditMode" exitedEditMode="ExitedEditMode" exitingEditMode="ExitingEditMode"></ig:gridClientEvents>
<f:facet name="header">
<h:outputText value="Employee List"></h:outputText>
</f:facet>
<ig:column>
<h:outputText value="First Name"></h:outputText>
<h:outputText value="#{DATA_ROW.firstName}"></h:outputText>
</ig:column>
<h:outputText value="Last Name"></h:outputText>
<h:outputText value="#{DATA_ROW.lastName}"></h:outputText>
<h:outputText value="e-mail"></h:outputText>
<h:outputText value="#{DATA_ROW.email}"></h:outputText>
<h:outputText value="Phone number"></h:outputText>
<h:outputText value="#{DATA_ROW.phoneNumber}"></h:outputText>
</ig:gridView>
</f:view>
</body>
In that example you check if the row number is divisible by 3 and these rows cannot be modified because we cancel the event:
args.set_cancel(true);
Regards!