如何在asp.net mvc的kendo ui网格编辑中自定义弹出窗口

时间:2015-03-26 13:34:32

标签: asp.net-mvc-4

如何在用于asp.net mvc的kendo ui网格编辑中自定义弹出窗口?

这段代码不行。

我也有一个弹出式Uploader 你能救我吗?

`
@(Html.Kendo().Grid<CMS_Test.Models.ProductViewModel>()
 .Name("grid")
 .Columns(columns =>
{
    columns.Bound(p => p.Id).Title("شماره ردیف").Width(130);
    columns.Bound(p => p.Pname).Width(100).Title("نام").Width(180);
    columns.Bound(p => p.price).Width(100).Title("قیمت").Width(180);

    columns.Template(@<text></text>)
        .ClientTemplate(
            "<a href='" + Url.Action("GetID", "Product")      +"/#=Id#'>مشاهده جزییات</a>");

    columns.Template(@<text></text>)
        .ClientTemplate(

              "<img src='/Images/baby.jpg'   width='100'/>");

    columns.Command(command => { command.Edit().Text("ویرایش"); command.Destroy().Text("حذف"); }).Width(180).Title("هزینه");
})
.ToolBar(toolbar => toolbar.Create().Text("ایجاد رکورد جدید"))
        .Editable(editable =>   editable.Mode(GridEditMode.PopUp)).ClientDetailTemplateId("popupEditorTemplate")
     .Events(e => e.Edit("onEdit"))
.Pageable()
.Sortable()
.Scrollable()

    // .HtmlAttributes(new { style = "height:200px;" })
.DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(5)

    .Events(events => events.Error("error_handler"))
.Model(model =>
                {
                    model.Id(p => p.Id);
                    model.Field(p => p.Id).Editable(false);

                }
            )

        .Create(update => update.Action("EditingPopup_Create", "Product"))
        .Read(read => read.Action("EditingPopup_Read", "Product"))
            .Update(update => update.Action("EditingPopup_Update", "Product"))
            .Destroy(update => update.Action("EditingPopup_Destroy", "Product"))
           )
     )
   <script type="text/javascript">
      function error_handler(e) {
         if (e.errors) {
         var message = "Errors:\n";
         $.each(e.errors, function (key, value) {
            if ('errors' in value) {
                $.each(value.errors, function () {
                    message += this + "\n";
                });
            }
         });
        alert(message);
       }
      }
      </script>

   <script id="popupEditorTemplate" type="text/x-kendo-template">
   <div class="form-horizontal">
    @Html.HiddenFor(c => c.Id)
    @Html.TextBoxFor(c => c.Pname)
    </div>
    referferferf
    fderfreferferferf
     </script>
   <script>
     function onEdit(e) {
     //failed attempt to setup the template on the client after the fact
      return e.editable.template =   kendo.template($("#popupEditorTemplate").html());

}
</script>`

0 个答案:

没有答案