2013-01-06 3 views
0

Почему, когда я нажимаю кнопку вставки в сетке, действие не вызывается. Я установил точку останова в действии, но действие не вызвало. Это мое действие:Вставить действие в сетку telerik в mvc 3

[AcceptVerbs(HttpVerbs.Get)] 
[GridAction] 
public ActionResult _InsertAjaxEditing() 
{ 
    return View(); 
} 

[AcceptVerbs(HttpVerbs.Post)] 
[GridAction] 
public ActionResult _InsertAjaxEditing(Employee e) 
{ 
    bus = new SysBusContext(); 
    string error = null; 
    IEnumerable<Employee> emps = null; 
    if (e != null) 
     if (e.EmployeeId != null) 
     { 
      try 
      { 
       Employee emp = new Employee(); 
       emp = e; 
       bus.Employees.Add(emp); 
       bus.SaveChanges(); 
      } 
      catch 
      { 
      } 
     } 
    emps = bus.Employees.ToList(); 
    return View("EmpSave", emps); 
} 

и это мое мнение:

<div class="t-rtl"> 
@(Html.Telerik().Grid<TelerikMvcApplication3.Models.Employee>() 
     .Name("Grid") 
     .DataKeys(keys => 
     { 
      keys.Add(p => p.EmployeeId); 
     }) 
     .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.ImageAndText). 
      ImageHtmlAttributes(new {style="margin-Right:0"})) 
     .DataBinding(dataBinding => 
     { 
      dataBinding.Ajax() 
       .Select("_SelectAjaxEditing", "CtrlEmployee") 
       .Insert("_InsertAjaxEditing", "CtrlEmployee") 
       .Update("_SaveAjaxEditing", "CtrlEmployee") 
       .Delete("_DeleteAjaxEditing", "CtrlEmployee"); 
     }) 
     .Columns(columns => 
     { 
      columns.Bound(p => p.EmployeeId).Width(95); 
      columns.Bound(p => p.FirstName).Width(50).Sortable(true); 
      columns.Bound(p => p.LastName).Width(50).Sortable(true); 
      columns.Bound(p => p.Recruitment).Width(70);//.ClientTemplate(@Html.Telerik().DatePicker(); 
      columns.Bound(p => p.Email).Width(100).Format("{0:d}"); 
      columns.Bound(p => p.PhoneNumber).Width(65); 
      columns.Bound(p => p.Type).Width(50); 
      columns.Command(commands => 
      { 
       commands.Edit().ButtonType(GridButtonType.ImageAndText); 
       commands.Delete().ButtonType(GridButtonType.ImageAndText); 
      }).Width(180).Title("ویرایش"); 
     }).ClientEvents(e => e 
      .OnDataBinding(
       @<text> function(a) { a.data = $.extend(a.data,{ dropdownlist: $('#dropdownlist').val()}); } 
       </text>) 
      ) 
      .Editable(t => t.Mode(GridEditMode.PopUp)) 
     .Pageable() 
     .Scrollable() 
     .Sortable()  
) 

</div> 


@section HeadContent 
{ 
<style type="text/css"> 

    .t-widget, .t-widget .t-input, .t-widget .text-box, .t-button { 
    font-family: tahoma; 
    font-size: 100%; 
    } 


    .field-validation-error 
    { 
     position: static; 
     right: 50px; 
     top: -15px; 
    } 

    * html .field-validation-error { position: relative; } 
    *+html .field-validation-error { position: relative; } 

    .field-validation-error span 
    { 
     position: absolute; 
     white-space: nowrap; 
     color: red; 
     padding: 17px 5px 3px; 
     background: transparent url('@Url.Content("~/Content/Common/validation-error-message.png") ') no-repeat 0 0; 
    } 

    /* in-form editing */ 
    .t-edit-form-container 
    { 
     width: 460px; 
     margin: 1em; 

    } 

    .t-edit-form-container .editor-label{ float: right;} 
    .t-edit-form-container .editor-field 
    { 
     padding-bottom: 1em; 
     float: right; 
    } 

    .t-edit-form-container .editor-label 
    { 
     width: 30%; 
     text-align: right; 
     padding-right: 3%; 
     clear: right; 
    } 

    .t-edit-form-container .editor-field 
    { 
     width: 60%; 
     font: 
    } 

    #GridPopUp 
     { 
      position:fixed; 
      top:10px; 
      } 

</style> 

ответ

0

попробуйте удалить этот

--> [AcceptVerbs(HttpVerbs.Get)] - 
[GridAction] 
public ActionResult _InsertAjaxEditing() 
{ 
    return View(); 
} 

возможно Прошение POST

или

т ry удалить это

[AcceptVerbs(HttpVerbs.Get)] - 
--> [GridAction] 
public ActionResult _InsertAjaxEditing() 
{ 
    return View(); 
} 
Смежные вопросы