2012-12-27 4 views
1

검도 UI가 새로 도입되었습니다. JSON 형식의 asmx webservice에서 채울 표가 있습니다. 데이터를 잘 표시합니다. 나는 편집을 가능하게했지만 업데이트 버튼을 클릭해도 아무 일도 일어나지 않고, 내 웹 메소드에서 중단 점에 도달하지 못했습니다.검도 UI 격자가 웹 서비스를 호출하지 않습니다.

다음은 관련 코드 스 니펫입니다. 감사

//references 
    <link href="Content/kendo/2012.3.1114/kendo.common.min.css" rel="Stylesheet" /> 
    <link href="Content/kendo/2012.3.1114/kendo.default.min.css" rel="Stylesheet" /> 

    <script src="Scripts/jquery-1.8.3.js" type="text/javascript"></script> 
    <script src="Scripts/kendo/2012.3.1114/kendo.web.min.js" type="text/javascript"></script> 


//Data Model Classes 
    [Serializable] 
    public class Make 
    { 
     public int PhoneMakeID { get; set; } 
     public string PhoneMakeDesc { get; set; } 
     public string BillingDesc { get; set; } 
    } 


//Web Methods 
    //Phone Make Get that populates the grid, works 100%  
     [WebMethod] 
     [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
     public List<Make> GetPhoneMakes(string Active, string OfferTypeID, string TrackMonthID, string NetworkID) 
     { 
      DataTable dtPhoneMakes = new DataTable(); 

      Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase("PricingConnection"); 
      DbCommand dbCommand = null; 
      dbCommand = db.GetStoredProcCommand("uspPS_PhoneMake_Get"); 
      db.AddInParameter(dbCommand, "@OfferTypeID", DbType.String, OfferTypeID); 
      db.AddInParameter(dbCommand, "@TrackMonthID", DbType.String, TrackMonthID); 
      db.AddInParameter(dbCommand, "@NetworkID", DbType.String, NetworkID); 
      db.AddInParameter(dbCommand, "@Active", DbType.String, Active); 

      dtPhoneMakes = db.ExecuteDataSet(dbCommand).Tables[0]; 

      List<Make> ml = new List<Make>(); 
      Make m; 

      foreach (DataRow dr in dtPhoneMakes.Rows) 
      { 
       m = new Make(); 
       m.PhoneMakeID = Convert.ToInt32(dr["PhoneMakeID"].ToString()); 
       m.PhoneMakeDesc = dr["PhoneMakeDesc"].ToString(); 
       m.BillingDesc = dr["BillingDesc"].ToString(); 

       ml.Add(m); 
      } 

      return ml; 
     } 


//Phone Make Update, not getting to here 
     [WebMethod] 
     [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
     public void UpdatePhoneMakes(string PhoneMakeID, string PhoneMakeDesc, string BillingDesc) 
     { 
      Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase("PricingConnection"); 
      DbCommand dbCommand = null; 
      dbCommand = db.GetStoredProcCommand("uspPS_PhoneMake_Update"); 
      db.AddInParameter(dbCommand, "@PhoneMakeID", DbType.String, PhoneMakeID); 
      db.AddInParameter(dbCommand, "@PhoneMakeDesc", DbType.String, PhoneMakeDesc); 
      db.AddInParameter(dbCommand, "@BillingDesc", DbType.String, BillingDesc); 

      db.ExecuteNonQuery(dbCommand); 

     } 

//Transports 
      var transpPhoneMake = { 
       read: function (options) { 
        $.ajax({ 
         type: "POST", 
         url: "webmethods/phones.asmx/GetPhoneMakes", 
         contentType: "application/json; charset=utf-8", 
         data: jdPhoneMake, 
         dataType: 'json', 
         success: function (msg) { 

          options.success(msg); 
         } 
        }); 
       }, 
       update: function (options) { 
        url: "webmethods/phones.asmx/UpdatePhoneMakes/"; 
        contentType: "application/json; charset=utf-8";      
        type: "POST"; 
       }, 
       parameterMap: function (data, operation) { 
        if (operation != "read") {        
         return JSON.stringify({ products: data.models }) 
        } 
        else {       
         data = $.extend({ sort: null, filter: null }, data); 
         return JSON.stringify(data); 
        } 
       } 
      }; 


//DataSources 
      var dsPhoneMake = new kendo.data.DataSource({ 
       transport: transpPhoneMake, 
       schema: 
       { 
        data: "d", 
        total: "d.length", 
        model: 
        { 
         id: "PhoneMakeID", 
         fields: 
         { 
          PhoneMakeID: { type: "string", editable: false, nullable: true }, 
          PhoneMakeDesc: { type: "string", editable: true }, 
          BillingDesc: { type: "string", editable: true } 
         } 
        } 
       }, 
       pageSize: 10, 
       sort: 
       { 
        field: "PhoneMakeDesc", 
        dir: "asc" 
       } 
      }); 


//Grids 
       var gridPhoneMakes = $("#gridPhoneMakes").kendoGrid({ 
        dataSource: dsPhoneMake, 
        columns: 
         [ 
          { command: ["edit", "destroy"], title: "&nbsp;", width: "175px" }, 
          { 
           field: "PhoneMakeID", 
           title: "Make ID", 
           filterable: false, 
           editable: false, 
           width: 75 
          }, 
          { 
           field: "PhoneMakeDesc", 
           title: "Make Description", 
           editable: true 
          }, 
          { 
           field: "BillingDesc", 
           title: "Make Code", 
           editable: true 
          } 
         ], 
        toolbar: kendo.template($("#tmplPhoneMakeToolbar").html()), 
        selectable: "row", 
        sortable: true, 
        groupable: true, 
        pageable: true, 
        filterable: true, 
        autoBind: false, 
        editable: "inline", 
        batch: false 
       }); 

답변

4

귀하의 transport 정의는 말한다 : 당신이 실제로 함수를 정의하지 않는 경우

update: function (options) { 
    url: "webmethods/phones.asmx/UpdatePhoneMakes/"; 
    contentType: "application/json; charset=utf-8";      
    type: "POST"; 
}, 

. 해야 파괴 작성, 갱신 및 - 전송 방법은 일관성이 있어야합니다 :

참고 모든 transport 정의가 일치해야

update: { 
    url: "webmethods/phones.asmx/UpdatePhoneMakes/", 
    contentType: "application/json; charset=utf-8", 
    type: "POST", 
}, 

그러나 (KendoUI 문서에서 발췌) : 그것은 뭔가를해야한다 함수로도 지정됨

(감사의 말로 @LindsySimon)

당신이 read을 위해했던 것처럼

당신은 수행해야합니다

read: function (options) { 
    $.ajax({ 
     url: "webmethods/phones.asmx/UpdatePhoneMakes/", 
     contentType: "application/json; charset=utf-8", 
     type: "POST", 
     success: function (result) { 
      ... 
     } 
    }); 
} 
+1

난 당신이 하나 개의 전송 방식에 함수를 사용하는 경우, 당신은 * 모든 * 방법에 대한 함수를 사용해야합니다 믿습니다. –

+0

저는 OP가 아닙니다. 두 번째 예제가 이미 그를 위해 일한다고 생각하지 않았습니다. 왜냐하면'read'가 이미 함수로 정의되어 있기 때문입니다. –

+0

죄송합니다. 질문에 대한 오해가 있었으며 원본이 잘못되었다고 생각하는 이유에 대해 궁금해 하셨다고 생각합니다. 내 소식을 수정하고 +1합니다. 감사! – OnaBai

관련 문제