2011-05-02 3 views
1

간단한 문제는 누구나 도와 줄 수 있습니까? jqGrid (v4.0.0)에서 사용할 수있는 JSON 데이터를 Google App Engine에 제공하려고 시도하고 있지만 건너 뛸 최종 울타리가있는 것 같습니다. 그러나 때Appengine의 ProtoRPC와 함께 작동하는 jqGrid를 얻는 방법

 jQuery("#tasklist").jqGrid({ 
     url:'http://localhost:8084/postservice.get_tasks', 
     datatype: 'json', 
     mtype: 'GET', 
     colNames:['Task','Folder', 'Context','Status'], 
     colModel :[ 
      {name:'title', index:'Task', width:120}, 
      {name:'folder', index:'Folder', width:40}, 
      {name:'context', index:'Context', width:32}, 
      {name:'status', index:'Status', width:32} ], 
     pager: jQuery('#pager'), 
     rowNum:10, 
     jsonReader: {repeatitems:false, cell:'' }, 
     rowList:[10,20,30], 
     sortname: 'folder', 
     sortorder: "desc", 
     viewrecords: true, 
     imgpath: 'themes/basic/images', 
     caption: 'My Jobs' 
     }); 

: 나는 다음있는 jqGrid 설정이 데리러하려고

{ 
rows: [ 
    { 
    status: Planning, 
    folder: HPM, 
    context: WORK, 
    title: PURSUE HPM ACTIONS, 
    }, 
    { 
    status: Planning, 
    folder: PLANNED MAINTENANCE, 
    context: WORK, 
    title: PM ASBESTOS, 
    }, 

: 내 응용 프로그램은 내가 같은 출력을 얻을 ProtoRPC의 형태로 쿼리 인터페이스를 사용하여 간단한 할 일 목록의 예이며, 나는 두 개의 응답 중 하나를 얻을,이 코드를 실행 :

http://localhost:8084/postservice.get_tasks?_search=false&nd=1304325960695&rows=10&page=1&sidx=folder&sord=desc 
400 unrecognized RPC format 

내가 POST에 MTYPE을 변경하는 경우 : 내가 GET으로 MTYPE을두고 있다면,있는 jqGrid는 ProtoRPC에 의해 거부 된 URL 매개 변수를 전달하려고 그러면 200 OK 응답을 갖지만 그리드에는 데이터가 없으며 Firebug를 사용하면 데이터가 반환되었다는 어떠한 증거도 볼 수 없습니다.

나는 몇 가지 시도했지만, 여기에 내 기술의 한계에 도달했습니다 (열심히하지!) 어떤 도움을 주셔서 감사합니다.

  • JsonReader가 기본적으로 기대하는 다른 정보, 즉 총계, 페이지, 레코드 등을 반환하려면 ProtoRPC를 가져와야합니까?
  • 나는 Oleg's answer을 따르도록했지만, 난 그냥있는 jqGrid 설정의 앞에 제안 된 코드를 배치 할 때 나는 구문 오류를했고 요청이 실행되지 않습니다 :.

$ .extend ($ jgrid.defaults, 을 데이터 유형 : 'json', {ajaxGridOptions : {contentType : "application/json"}, {ajaxRowOptions : {contentType : "application/json", 유형 : "PUT"} }});

  • 난 그냥 ContentType을 추가하려고 않은 : 난 그냥 (무지가 행복이다)에있는 jqGrid 옵션에 "응용 프로그램/JSON을"하지만 내가 다시 정보를 얻고
  • 아마도 어떤 차이를 만들어,하지만 아니에요 방화범이 끌려 볼 때?

도움이 될 것입니다.


PS : 컬을 사용하여, 나는 너무 오래 내가 어떤 데이터를 게시하려고하지 않는 한, 예상 데이터를 반환 할 수 있어요 :

C:\Users\Staples1>curl -i -X POST -HContent-Type:application/json -HAccept:application/json http://localhost:8084/postservice.get_tasks
HTTP/1.0 200 OK Server:
Development/1.0 Date: Mon, 02 May 2011
16:55:19 GMT Cache-Control: no-cache
Content-Type: application/json
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 1069
{"rows": [{"status": "Planning", "folder": "HPM", "context": "WORK", "title": "P URSUE HPM ACTIONS"}, {"status": "Planning", "folder": "PLANNED MAINTENANCE", "co ntext": "WORK", "title": "PM ASBESTOS"}, {"status": "Next Action", "folder": "PL ANNED MAINTENANCE", "context": "WORK", "title": "Chase Brian on asbestos"}, {"st atus": "Undefined", "folder": "PLANNED MAINTENANCE", "context": "WORK", "title": "PM GAS"}, {"status": "Hold", "folder": "PLANNED MAINTENANCE", "context": "WORK ", "title": "Do PBS detail for Gas"}, {"status": "Hold", "folder": "PLANNED MAIN TENANCE", "context": "WORK", "title": "Do next Product Description for Gas Servi cing"}, {"status": "Hold", "folder": "DPA", "context": "WORK", "title": "Put sam ple privacy notices on Rosie"}, {"status": "Hold", "folder": "DPA", "context": " WORK", "title": "Customer Profiling Info"}, {"status": "Hold", "folder": "DPA", "context": "WORK", "title": "Write network access agreement for contractors/ thi rd parties"}, {"status": "Hold", "folder": "DPA", "context": "WORK", "title": "C ontact CMBC for agreement"}]}
C:\Users\Staples1>

을 그리고 네, 저는에서 노트북을 구입했다 물림쇠!


PPS : 문제는 계속 진행 중입니다.

는 마침내 다시 올렉의 응답을 읽고있는 jqGrid 옵션에 추가 : ProtoRPC에 응용 프로그램/JSON, 나는 같은 받고 있어요 : 나는 결국 ContentType이를 보내고 이제

ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },

내가 방화범에서 볼 수 나는 방화범이 끌려에서 게시 된 데이터를

File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\decoder.py", line 315, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\decoder.py", line 333, in raw_decode
raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded

을 완료하는 App Engine에서 컬, 즉 역 추적을 사용하여 데이터를 보내려고 할 때 얻을 백업하는 것이 오류 응답

입니다

특히 jsonic으로 보이지 않습니다. 유일한 장애물은 jqGrid가 데이터를 보내지 않거나 올바르게 형식화 된 JSON 데이터를 보내거나 ProtoRPC가 데이터를 무시하도록하는 것입니다.

제안 환영!

+0

여전히 파고 - 내가 올바르게 읽는다면 내 답변은 Paul Tiseo의 ** grid.postext.js ** 플러그인에있을 수 있습니다. 내가 그것을 가능하게하는 방법을 이해할 수만 있다면! – jaffamcneill

답변

0

꽤 좋지는 않지만 어떤 상을 수상하지는 않지만, jqGrid가 그리드 옵션에서 기본값을 null로 설정하여 ProtoRPC에 보내려고하는 매개 변수를 끌 수 있음을 발견했습니다.

prmNames: {nd:null, search:null, rows:null, page:null, sort:null, order:null}, 

이제 그리드가 채워집니다. 마지막으로 나는 출발 선에 도착했다.

그냥 요약하자면, 퍼즐의 다른 비트는

datatype: 'json', 
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }, 
mtype: 'POST', 

원숭이와 타자기이다. . .

관련 문제