Hi,
I need help with the data bind in the grid.
My requirement is to select data bind in the grid.
I am trying (RowDataBound) it working fine.
But (DataBound). does not work.
Do not need all data rendering in the grid, only selected data bind in the grid.
The HTML, script, and image are attached.
My requirement is,
I have multiple grids views and multiple datasources and i want to keep one datasource
the only difference between multiple grids is few targeted data will not view in one grid but will appear in other.
Currently, I created multiple datasource for each grid.
I have highlighted the rows in the attached video and want to filter the particular data and bind the filtered data to the grid at initial rendering.
<div class="control-section">
@Html.EJS().Grid("DefaultPaging").DataBound("DataBound").DataSource(ds => ds.Url("/Home/UrlDatasource").Adaptor("UrlAdaptor").InsertUrl("/Home/Insert").RemoveUrl("/Home/Remove").UpdateUrl("/Home/Update")).Columns(col =>
{
col.Type("checkbox").Width("50").Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("170").Add();
. . . . . . .
}).. . . . ..Render()
</div>
<script>
var flag = true;
function DataBound() {
if (flag) {
flag = false;
var predicate = new ej.data.Predicate('CustomerID', 'equal', "ANTON");
new ej.data.DataManager({ url: 'Home/UrlDatasource', adaptor: new ej.data.UrlAdaptor })
.executeQuery(new ej.data.Query().where(predicate))
.then((e) => {
var gridObj = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
gridObj.dataSource = e.result;
});
}
}
</script> |
Hi,
Thank you for solving the work on fine in the data-bound.
But in my case, it does not work next time when again grid render.
Can you please provide me the same solution? Created or Load functions.
Because my grids are inside of the Tabs with ajax call in partial view.
<div class="control-section">
@Html.EJS().Grid("DefaultPaging").Load("Load").. . . . .Render()
</div>
<script>
// This event allows customization of Grid properties before rendering.
function Load() {
var predicate = new ej.data.Predicate('CustomerID', 'equal', "ANTON");
new ej.data.DataManager({ url: 'UrlDatasource', adaptor: new ej.data.UrlAdaptor })
.executeQuery(new ej.data.Query().where(predicate))
.then((e) => {
var gridObj = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
gridObj.dataSource = e.result;
});
}
</script> |
Thanks, the provided solution is working fine.