Hello I need help to find how to write 2 events.
1_ OnDatabinding not exist in
2_ OnComplete not exist in
In KendoUI I not find how to write the events "DataBinding" and "Complete" to call javascript functions.
My javascript
My customBinding where I need an "int id"
So how can I write these two events for the grid?
1_ DataBinding
2_ Complete
In Telerik I have this:
UPDATE:
==================================
Now I made this change and the grid call the action
But it give me a null reference error on Sorts:
1_ OnDatabinding not exist in
Events(events => events.
...2_ OnComplete not exist in
Events(events => events.
...In KendoUI I not find how to write the events "DataBinding" and "Complete" to call javascript functions.
@(Html.Kendo().Grid(Model.Sors)
.Name("Grid")
.EnableCustomBinding(true)
.Columns(columns =>
{
columns.Bound(o => o.TransactionId).Width(20).Title("<
input
id
=
'selectAll'
type
=
'checkbox'
/").Sortable(false);
columns.Bound(o => o.StaffName).Width(100).Title(LocaleUtil.Get(GuestMessageKeys.StaffName));
columns.Bound(o => o.BuildingName).Width(100).Title(LocaleUtil.Get(BuildingMessageKeys.Building));
columns.Bound(o => o.DateTime).Width(120).Title(LocaleUtil.Get(GlobalMessageKeys.DateTime)).Format(TelerikUtil.GetShortDateTimeFormat());
columns.Bound(o => o.TransactionId).Width(30).Title(LocaleUtil.Get(GlobalMessageKeys.Change)).Sortable(false);
})
.Events(events => events.DataBound("Grid_OnDataBound"))
.Events(events => events.DataBinding("Grid_OnDataBinding"))
.Events(events => events.Complete("Grid_OnComplete"))
.DataSource(dataBinding => dataBinding
.Ajax()
.Read("_KCustomBinding", "MassSorUpdate", new { Area = "MassProcessing" })
.Total(Model.SorsTotal))
.Pageable()
.Sortable()
)
My javascript
// Send additional data to the grid action method, in this case the ComboBox selected value.
function
Grid_OnDataBinding(e) {
e.data = { id: $(
"#UpdateType"
).val() };
// uncheck select all combo
$(
"#selectAll"
).attr(
"checked"
,
false
);
}
var
totalGridRecords = 0;
function
Grid_OnComplete(e) {
totalGridRecords = e.response.total;
}
function
Grid_OnDataBound(e) {
e.row.cells[0].innerHTML =
"<input type='checkbox' name='checkedRecords' value='"
+ e.dataItem.TransactionId +
"' />"
;
e.row.cells[4].innerHTML =
"<a href='javascript:;' onclick='ShowSorDetailPopup( { transactionId: \""
+e.dataItem.TransactionId+
"\"})'>"
+ msgDetail +
"</a>"
;
}
My customBinding where I need an "int id"
[GridAction(EnableCustomBinding =
true
)]
public
ActionResult _KCustomBinding([DataSourceRequest(Prefix =
"Grid"
)] DataSourceRequest request,
int
id)
{
if
(request.PageSize == 0)
{
request.PageSize = 10;
}
ViewClientFilter<SorDTO> viewClientFilter =
new
ViewClientFilter<SorDTO>();
viewClientFilter.AddPageCount(request.PageSize);
viewClientFilter.AddPageIndex(request.Page);
ClientFiltersResponse<SorDTO> list =
this
.MassSorUpdateRepository.GetMassSorUpdatesList(id, viewClientFilter);
return
View(
new
GridModel
{
Data = list.Data,
Total = list.Total
});
}
So how can I write these two events for the grid?
1_ DataBinding
2_ Complete
In Telerik I have this:
....
.ClientEvents(s => s.OnRowDataBound("Grid_OnDataBound"))
.ClientEvents(s => s.OnDataBinding("Grid_OnDataBinding"))
.ClientEvents(s => s.OnComplete("Grid_OnComplete"))
.DataBinding(dataBinding => dataBinding.Ajax().Select("_CustomBinding", "MassSorUpdate", new { Area = "MassProcessing" }))
.Pageable(settings => settings.Total(Model.SorsTotal))
.EnableCustomBinding(true)
.Sortable()
UPDATE:
==================================
Now I made this change and the grid call the action
.Ajax()
// Enable batch mode
.Batch(true)
.Read(read => read.Action("_KCustomBinding", "MassSorUpdate", new { Area = "MassProcessing" })
.Data("Grid_OnDataBinding"))
.Total(Model.SorsTotal)
But it give me a null reference error on Sorts:
if
(request.Sorts.Count == 0) <= Sorts is = null or undefined