我在我的项目中使用 Telerik 控件,任何主体都告诉如何在 Telerik 网格视图中获取选择更改事件,该事件可以在插入、编辑中填充多个列文本框。那是在 mvc3+razor(cshtml) 中。
编辑器模板代码
@model string
<table>
<tr>
<td>
@(Html.Telerik().ComboBoxFor(e => e)
.BindTo(ViewBag.pro as SelectList)
.ClientEvents(events => events.OnChange("getproductdesc")) )
</td>
<td>
</td>
<td>
@Html.TextBoxFor((model => model), new { id = "textbox" })
</td>
</tr>
</table>
<script type="text/javascript">
function getproductdesc(e) {
var idmodel = $(this).val();
alert(idmodel);
$('#textbox').val($(this).val());
}
</script>
网格视图代码
@(Html.Telerik().Grid(Model)
.Name("gdProductDetails")
.ToolBar(commands => commands.Insert())
.DataKeys(keys => keys.Add(c => c.Product_cd))
.Pageable(paging =>
paging.PageSize(5)
.Style(GridPagerStyles.NextPreviousAndNumeric)
.Position(GridPagerPosition.Bottom))
.Sortable(sorting => sorting
.SortMode(GridSortMode.MultipleColumn))
.DataBinding(databing => databing.Server()
// .Select("DCProductDetails", "DeliveryChallan")
.Insert("Addproduct", "DeliveryChallan")
.Update("Editproduct", "DeliveryChallan")
.Delete("Delete", "Home"))
.Columns(columns =>
{
columns.Bound(c => c.Sl_no);/*EditorTemplateName("Product")*/
columns.Bound(c => c.Product_cd).EditorTemplateName("product").Width(350);
columns.Bound(c => c.Prouduc_desc).ClientTemplate("<input type='text' id='textbox'/>");
columns.Bound(c => c.Prod_rt);
columns.Command(commands =>
{
commands.Edit();
commands.Delete();
});
})
)
</table>
</fieldset>
控制器代码
var listproduct = (from i in db.MSM_PRODUCT select i);
ViewBag.pro = new SelectList(listproduct, "PRODUCT_DESC", "PRODUCT_CD");