2013-04-17 2 views
7

이제 kendo 내장 편집 윈도우 대신 사용자 정의 팝업 kendoWindow를 사용하여 그리드 데이터를 누설하려고 할 때 kendoui로 웹 앱을 개발하는 방법을 배우고 있습니다. 어떻게 원격 요청을 보낼 봉사, 그래서 난 this page에 공식 API 문서에서 답을 찾기 위해 노력하지만 새로운 문제가 추적 코드로, 쇼를 발생있다 : 그것은 설명하기위한 예입니다kendo 데이터 소스의 'options'매개 변수

<script> 
    var dataSource = new kendo.data.DataSource({ 
     transport: { 
      read : function (options) { 
       /* implementation omitted for brevity */ 
      }, 
      update: function (options) { 
       // make JSONP request to http://demos.kendoui.com/service/products/update 

       $.ajax({ 
        url  : "http://demos.kendoui.com/service/products/update", 
        dataType: "jsonp", // "jsonp" is required for cross-domain requests; use "json" for same-domain requests 
        // send the updated data items as the "models" service parameter encoded in JSON 
        data : { 
         models: kendo.stringify(options.data.models) 
        }, 
        success : function (result) { 
         // notify the data source that the request succeeded 

         options.success(result); 
        }, 
        error : function (result) { 
         // notify the data source that the request failed 
         options.error(result); 
        } 
       }); 
      } 
     }, 
     batch : true, 
     schema : { 
      model: { id: "ProductID" } 
     } 
    }); 

    dataSource.fetch(function() { 
     var product = dataSource.at(0); 
     product.set("UnitPrice", 20); 
     dataSource.sync(); makes request to http://demos.kendoui.com/service/products/update 
    }); 
</script> 

원격 서비스에 HTTP 요청을하는 함수로 업데이트를 지정하는 방법

내 문제는 'options'매개 변수는 무엇입니까? 읽기 및 업데이트 기능으로 전달됩니다. 내가 찾은 유일한 단서는 transport.parametermap 함수의 매개 변수입니다. 그러나 그들 사이에 특정 관계가 있는지 확신 할 수 없으므로 누군가 나를 위해 설명해 주길 바랍니다.

답변

5

options 매개 변수는 이미 발견 한 것입니다. KendoUI에서는 데이터 소스 클래스의 데이터 액세스 메서드에 대한 일부 구성 대신 함수를 지정합니다.

함수를 지정하면 kendoUI가 데이터로드가 완료된 시점을 어떻게 알 수 있습니까? 그것은 할 수 없었다. 그래서 kendoUI가 여러분의 진행 상황을 알 수 있도록 호출 할 수있는이 옵션 변수가 함수에 전달됩니다 (실제로는 모든 이름을 가질 수 있습니다 (예 : dfhajkfhd). 여기에는 성공오류 전화 할 수 있습니다.

kendo-docs에서 복사 한 귀하의 의견은 정확하게 말합니다.

다른 질문이 있습니까?

+0

리얼 덕분에 사용되는 코드입니다. 예, 제가 링크 된 문서에서 답변을 찾았습니다. – Beicai

1

정말이 질문에 대한 답변과 내가 질문에 링크 된 검도 - 문서의 아래쪽에서 답을 찾았습니다

하려고 한 사람을 주셔서 감사합니다.

  1. 새로운 DataSource를 '객체를 생성하고 그 안에 읽어 및 업데이트 전송을 정의
  2. 데이터 소스는 준비, 난에 의해 을 UDPATE하는 데 필요한 데이터 항목을 얻을 수 은 dataSource의'수 '방법을 사용하는 경우 신분증.
  3. UDPATE 데이터가 '설정'방법을 사용하고 마지막 단계는 데이터베이스 추적에 데이터를 동기화한다

'동기화'의 방법으로 제출 내가 대답

var updateDataSource = new kendo.data.DataSource({ 
    type: "odata", 
    transport: { 
     read: { 
      url: "/api/odata/PEMEP/TaskInformations/?" 
     }, 
     update: { 
      url: "/api/odata/PEMEP/TaskInformations/?", 
      type: "PUT", 
      dataType: "json", 
     }, 
    }, 
    schema: { 
     model: { 
      id: "_id" 
     } 
    }, 
    sync: function() { // close edit window when update request finished 

     $("#window").data("kendoWindow").close(); 
    }, 
    error: function(e) { 
     console.log(e.status); 
    } 
}); 
updateDataSource.fetch(function() { 

    var task = updateDataSource.get(id); // get dataitem by id 

    task.set("status", status); // set new values 
    task.set("retreatReason", retreatReason); 

    updateDataSource.sync(); //submit the change 
}); 
관련 문제