<body>
<script type="text/x-jsrender" id="ImageColumnScript">
<button class="imageButton">Get Row Id</button>
</script>
<ej:TreeGrid ID="Treegrid" runat="server" //… >
<Columns>
<ej:TreeGridColumn HeaderText="View" Field="View" IsTemplateColumn="true"
TemplateID="ImageColumnScript"/>
</Columns>
//…
</ej:TreeGrid>
<script>
function Redirect() {
window.location = "Home.aspx";
}
$("#Treegrid").on("click", ".imageButton", function (e) {
var $tr = $(e.target).closest('tr'),
treeObj = $("#Treegrid").data("ejTreeGrid"),
rowIndex = ($tr).index(),
record = treeObj.model.currentViewData && treeObj.model.currentViewData[rowIndex],
id = record.Id;
$.ajax({
type: 'POST',
url: 'TreeGridDefault.aspx/RowID',
data: JSON.stringify({ "id": id }),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (data) {
window.location = "Home.aspx";
}
});
});
</script>
|