<ej-grid id="FlatGrid" allow-paging="true" action-failure="actionFailure">
<e-datamanager json="(IEnumerable<object>)ViewBag.datasource" update-url="NormalUpdate" insert-url="NormalInsert" remove-url="Home/NormalDelete" adaptor="remoteSaveAdaptor" />
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" edit-mode="@(EditMode.Normal)"></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add","edit","delete","update","cancel" })"></e-toolbar-settings>
<e-columns>
. . .
<e-column template="#temp1" field="Verified"></e-column>
<e-column template="#temp2" field="EmployeeID"></e-column>
</e-columns>
</ej-grid>
<script type="text/x-jsrender" id="temp1">
{{if Verified}}
<input id="Verified" class="checkbox" name="Verified" type="checkbox" checked />
{{else}}
<input id="Verified" class="checkbox" name="Verified" type="checkbox" />
{{/if}}
</script>
<script type="text/x-jsrender" id="temp2">
@*here we can show or hide the input text box based on that checkbox value*@
{{if Verified}}
<input id="EmployeeID" name="EmployeeID" type="number" value="{{:EmployeeID}}" />
{{else}}
<input id="EmployeeID" name="EmployeeID" type="hidden" value="{{:EmployeeID}}" />
{{/if}}
</script>
<script type="text/javascript">
$(document).on("change", "input[name='Verified']", function () {
if (this.checked) {
$(this).parents('tr').find('input[name="EmployeeID"]').attr("type", "number"); //shown the input box dynamically change checkbox the value
}
else
$(this).parents('tr').find('input[name="EmployeeID"]').attr("type", "hidden"); //hide the input box dynamically change the checkbox value
});
</script> |
Hi Venkatesh:
Thanks for your support. I have only one question.
Would be possible inside the $(document).on("change", "input[name='Selected']", function ()
to get the underlying data row from the datasource to be able to read a particular value related with the record whose checkbox was clicked.
For example suppose that we need to show the texbox after the checkbox is checked ONLY when a field named "AllowChange" that is in the datasource (not rendered in the grid) has a value of True.
Thanks again
David
$(document).on("change", "input[name='Verified']", function () {
var gridObj = $("#FlatGrid").ejGrid("instance"), row = $(this).parents('tr'), currentViewData = gridObj.getCurrentViewData(), index=gridObj.getIndexByRow(row);
var changedRowDetails = currentViewData[index];//here we can get the details of checked/unchecked the row details
console.log(changedRowDetails);
if (this.checked) {
$(this).parents('tr').find('input[name="EmployeeID"]').attr("type", "number"); //shown the input box dynamically change checkbox the value
}
else
$(this).parents('tr').find('input[name="EmployeeID"]').attr("type", "hidden"); //hide the input box dynamically change the checkbox value
});
|