问题
Hi I would like to ask how can i filter the current contents of the Telerik mvc grid by the selected value in Html.Telerik().DropDownList?
I think there's some js scripts needed which I'm figuring out.
Thanks in advance.
-Lawrence
回答1:
In your dropdownlist's onchange event:
.ClientEvents(events => events
.OnChange(
@<text> function(e) { $('NameOfGrid').data('tGrid').rebind(); }
</text>))
and in your grid's ondatabinding event:
.ClientEvents(e => e
.OnDataBinding(
@<text> function(a) { a.data = $.extend(a.data,{ dropdownlist: $('#dropdownlist').val()}); }
</text>)
)
In your controller, add the dropdownlist parameter to your GridAction and perform your action.
来源:https://stackoverflow.com/questions/11357333/filtering-telerik-mvc-grid-by-html-telerik-dropdownlist