Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143555 | Mar 26,2019 02:54 PM UTC | Apr 3,2019 04:31 AM UTC | ASP.NET MVC - EJ 2 | 3 |
![]() |
Tags: Grid |
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource).Columns(col =>
{
...
col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add();
}).AllowPaging().RowSelecting("rowSelecting").Created("created").RowDataBound("rowDataBound").Render()
<script>
var selIndex = [];
function rowDataBound(args) {
if (args.data['CustomerID'] == 'ANTON') {
selIndex.push(parseInt(args.row.getAttribute('aria-rowindex'))); // push the row index when match data
}
}
function rowSelecting(args) {
if (args.target && args.target.parentElement.classList.contains("e-checkbox-wrapper") && args.data['CustomerID'] != 'ANTON') {
args.cancel = true; //Cancels the default select all rows action
}
}
function created(args) {
document.getElementsByClassName("e-checkselectall")[0].nextSibling.addEventListener('click', function (e) {//Bind the click event to selectAll checkbox
if (!document.getElementsByClassName("e-checkselectall")[0].checked) {
this.selectRows(selIndex); //Select the specific rows in Grid
setTimeout(function () {
document.getElementsByClassName("e-checkselectall")[0].checked = true;
}, 1);
}
else {
this.clearSelection(); //Clear the selection in Grid
setTimeout(function () {
document.getElementsByClassName("e-checkselectall")[0].checked = false;
}, 1);
}
}.bind(this))
}
</script>
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.