Hello,
I'm trying to utilize some server side filtering as we have a lot of records to filter through and it doesn't make too much sense to do it on the client side.
@(Html.Kendo().Grid<SM.Domain.Med.Explant>()
.Name(
"grid"
).Scrollable(c => c.Enabled(
true
).Height(1000))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action(
"ExplantKendoInitializer"
,
"MedDevice"
,
new
{ status = Model.Status }).Data(
"explantsReadData"
))
)
.Columns(columns =>
{
columns.Bound(c => c.Device.DeviceType.Name)
.Width(180)
.Title(
"Type"
)
.HtmlAttributes(
new
{ id =
"typeDropdown"
})
.Filterable(filterable => filterable
.Cell(cell => cell
.DataTextField(
"Name"
)
.ShowOperators(
false
)
.InputWidth(170)
.Operator(
"contains"
)
.SuggestionOperator(FilterType.Contains)
.Template(
"deviceTypeFilter"
)
)
);
.Filterable(filterable => filterable
.Extra(
false
)
.Messages(m => m.Info(
"Items equal to:"
))
.Operators(operators => operators
.ForString(str => str.Clear()
.IsEqualTo(
"Is Equal To"
)
.Contains(
"Contains"
)
)
This is the bulk of what most of the grid looks like.
Below is the explantsReadData function that I am referencing in the .Read portion of the DataSource
function
explantsReadData() {
return
{
type: $(
'#typeDropdown'
)
};
}
And the filterable function that we are using if that is of any help.
function deviceTypeFilter(element) {
element.element.kendoDropDownList({
dataSource: @(Html.Raw(Json.Serialize(Model.Filters.DeviceTypes))),
optionLabel:
"--Select Device Type--"
,
});
}
I'm trying to pass the parameter into the ExplantKendoInitializer where I am making a DataSourceRequest. However type always returns as null. I'm not sure of the best way to set an Id or Name to the drop down list which has all of what I need to filter against.
If there is something I'm missing, or a better way to approach this, please let me know.
Be well,
Bradley