0

サーブレットから取得した JSON データ オブジェクトをバインドしようとしています。

$("#mainVerticalMenu").kendoMenu({
            dataSource : new kendo.data.DataSource({
                  transport: {
                      read: {
                          url: "net/samso/action/MenuAction?func_flag=getMenu&user_id=nexol", // the servlet url
                          dataType: "json",
                      }
                  },
                  schema: { // describe the result format
                      model : {
                          fields : {
                            text : {
                                type : "string"
                            },
                            value : {
                                type : "string"
                            },
                            subItemList: [{                                    // Sub item collection
                                text : {
                                    type : "string"
                                },
                                value : {
                                    type : "string"
                                }
                            }]
                          }
                      }
                  }
            })
        });

サーブレットから、JSON 形式は次のようになります。

階層:

Text
Value
subItemList (ItemObject nested inside the menuitem)
   - Text
   - Value

JSON の例:

最終的には次のようになります。

[{"text":"OuterMenu1","value":"menu1","subItemList":[{"text":"subMenuItem1","value":"subMenu1"},{"text":"subMenuItem2","value":"subMenu2"}]}]

サーブレットを直接呼び出したときに受け取る実際の JSON:

[{"text":"Communication","value":"BASE_01","subItemList":[{"text":"상품소개조회","value":"BASE_01"},{"text":"공지사항","value":"BASE_02"},{"text":"의견수렴","value":"BASE_04"},{"text":"사용자관리","value":"BASE_05"},{"text":"받은쪽지","value":"BASE_07"},{"text":"보낸쪽지","value":"BASE_08"},{"text":"자유게시판","value":"BASE_09"},{"text":"매장/마진율 정보","value":"BASE_10"}]},{"text":"매입관리","value":"BUY_01","subItemList":[{"text":"입고/입고반품현황","value":"BUY_01"},{"text":"수평이동요청","value":"BUY_02"},{"text":"수평이동승인/조회","value":"BUY_03"}]},{"text":"판매관리","value":"SALE_01","subItemList":[{"text":"판매및반품등록","value":"SALE_01"},{"text":"판매및반품조회","value":"SALE_02"},{"text":"판매일보","value":"SALE_04"},{"text":"기간별판매현황","value":"SALE_05"},{"text":"판매순위분석","value":"SALE_06"},{"text":"판매순위표","value":"SALE_07"},{"text":"타사등록","value":"SALE_08"},{"text":"타사판매등록","value":"SALE_09"},{"text":"타사판매조회","value":"SALE_10"}]},{"text":"수불관리","value":"SUBUL_01","subItemList":[{"text":"상품주문등록","value":"SUBUL_01"},{"text":"상품주문조회","value":"SUBUL_02"},{"text":"미입고명세서","value":"SUBUL_10"},{"text":"일별수불현황","value":"SUBUL_04"},{"text":"재고현황","value":"SUBUL_05"},{"text":"수불 일/월보","value":"SUBUL_09"},{"text":"품목별수불현황","value":"SUBUL_08"},{"text":"재고조정","value":"SUBUL_11"},{"text":"타매장재고현황","value":"SUBUL_07"}]},{"text":"영업관리","value":"BUSS_01","subItemList":[{"text":"영업판매배치등록","value":"BUSS_01"},{"text":"영업판매조회","value":"BUSS_02"},{"text":"영업주문배치등록","value":"BUSS_03"},{"text":"영업주문조회","value":"BUSS_04"},{"text":"매장별 재고/수불현황","value":"BUSS_05"}]},{"text":"AS관리","value":"AS_01","subItemList":[{"text":"A/S의뢰 관리","value":"AS_01"}]},{"text":"관리자","value":"SUP_06","subItemList":[{"text":"기초코드관리","value":"SUP_06"},{"text":"시스템관리","value":"SUP_05"},{"text":"그룹관리","value":"SUP_02"},{"text":"그룹소속관리","value":"SUP_03"},{"text":"그룹권한관리","value":"SUP_04"},{"text":"매장등록현황","value":"SUP_01"},{"text":"마진율조회","value":"SUP_07"},{"text":"상품코드별권한등록","value":"SUP_08"},{"text":"거래처별상품권한등록","value":"SUP_09"},{"text":"마감현황","value":"SUP_10"},{"text":"SAP송수신기록조회","value":"SUP_12"}]},{"text":"회계","value":"ACCT_01","subItemList":[{"text":"WEB-POS 사용자현황","value":"ACCT_01"},{"text":"WEB-POS 입금등록","value":"ACCT_02"}]}]

2 つの質問をしたい:

  1. データソースでトランスポート URL を明示的に宣言したにもかかわらず、サーブレットはまったく呼び出されません。

  2. 上記のスキーマは、外側のメニュー項目を宣言し、その中に項目をネストするのに正しいですか?

4

1 に答える 1

2

DataSource剣道メニューはそのコンテンツをロードするための を定義していないため、サーブレットは呼び出されていません。しかし、それはあなたがそれを行うことができないという意味ではありません: はい、できます!

あなたがすべきことは次のとおりです。

  1. 空のメニューを定義します。
  2. データソースを定義します。
  3. DataSource で読み取りを手動でトリガーする
  4. 受信したデータを元のメニューに追加します。

コード:

var menu = $("#menu").kendoMenu({}).data("kendoMenu");
var ds = new kendo.data.DataSource({
    transport: {
        read: {
            url     : "menu.json",
            dataType: "json"
        }
    },
    schema   : {
        data: function (data) {
            menu.append(data);
        }
    }
});
ds.read();

JSON の形式に関する 2 番目の質問について: で置き換えsubItemListitemsください。それだけです。JSON のエントリは次のようになります。

[
    {
        "text"       : "Communication",
        "value"      : "BASE_01",
        "items": [
            {
                "text" : "상품소개조회",
                "value": "BASE_01"
            },
            {
                "text" : "공지사항",
                "value": "BASE_02"
            },
            {
                "text" : "의견수렴",
                "value": "BASE_04"
            },
            {
                "text" : "사용자관리",
                "value": "BASE_05"
            },
            {
                "text" : "받은쪽지",
                "value": "BASE_07"
            },
            {
                "text" : "보낸쪽지",
                "value": "BASE_08"
            },
            {
                "text" : "자유게시판",
                "value": "BASE_09"
            },
            {
                "text" : "매장/마진율 정보",
                "value": "BASE_10"
            }
        ]
    },
    {
        "text"       : "매입관리",
        "value"      : "BUY_01",
        "items": [
            {
                "text" : "입고/입고반품현황",
                "value": "BUY_01"
            },
            {
                "text" : "수평이동요청",
                "value": "BUY_02"
            },
            {
                "text" : "수평이동승인/조회",
                "value": "BUY_03"
            }
        ]
    },
    {
        "text"       : "판매관리",
        "value"      : "SALE_01",
        "items": [
            {
                "text" : "판매및반품등록",
                "value": "SALE_01"
            },
            {
                "text" : "판매및반품조회",
                "value": "SALE_02"
            },
            {
                "text" : "판매일보",
                "value": "SALE_04"
            },
            {
                "text" : "기간별판매현황",
                "value": "SALE_05"
            },
            {
                "text" : "판매순위분석",
                "value": "SALE_06"
            },
            {
                "text" : "판매순위표",
                "value": "SALE_07"
            },
            {
                "text" : "타사등록",
                "value": "SALE_08"
            },
            {
                "text" : "타사판매등록",
                "value": "SALE_09"
            },
            {
                "text" : "타사판매조회",
                "value": "SALE_10"
            }
        ]
    },
    {
        "text"       : "수불관리",
        "value"      : "SUBUL_01",
        "items": [
            {
                "text" : "상품주문등록",
                "value": "SUBUL_01"
            },
            {
                "text" : "상품주문조회",
                "value": "SUBUL_02"
            },
            {
                "text" : "미입고명세서",
                "value": "SUBUL_10"
            },
            {
                "text" : "일별수불현황",
                "value": "SUBUL_04"
            },
            {
                "text" : "재고현황",
                "value": "SUBUL_05"
            },
            {
                "text" : "수불 일/월보",
                "value": "SUBUL_09"
            },
            {
                "text" : "품목별수불현황",
                "value": "SUBUL_08"
            },
            {
                "text" : "재고조정",
                "value": "SUBUL_11"
            },
            {
                "text" : "타매장재고현황",
                "value": "SUBUL_07"
            }
        ]
    },
    {
        "text"       : "영업관리",
        "value"      : "BUSS_01",
        "items": [
            {
                "text" : "영업판매배치등록",
                "value": "BUSS_01"
            },
            {
                "text" : "영업판매조회",
                "value": "BUSS_02"
            },
            {
                "text" : "영업주문배치등록",
                "value": "BUSS_03"
            },
            {
                "text" : "영업주문조회",
                "value": "BUSS_04"
            },
            {
                "text" : "매장별 재고/수불현황",
                "value": "BUSS_05"
            }
        ]
    },
    {
        "text"       : "AS관리",
        "value"      : "AS_01",
        "items": [
            {
                "text" : "A/S의뢰 관리",
                "value": "AS_01"
            }
        ]
    },
    {
        "text"       : "관리자",
        "value"      : "SUP_06",
        "items": [
            {
                "text" : "기초코드관리",
                "value": "SUP_06"
            },
            {
                "text" : "시스템관리",
                "value": "SUP_05"
            },
            {
                "text" : "그룹관리",
                "value": "SUP_02"
            },
            {
                "text" : "그룹소속관리",
                "value": "SUP_03"
            },
            {
                "text" : "그룹권한관리",
                "value": "SUP_04"
            },
            {
                "text" : "매장등록현황",
                "value": "SUP_01"
            },
            {
                "text" : "마진율조회",
                "value": "SUP_07"
            },
            {
                "text" : "상품코드별권한등록",
                "value": "SUP_08"
            },
            {
                "text" : "거래처별상품권한등록",
                "value": "SUP_09"
            },
            {
                "text" : "마감현황",
                "value": "SUP_10"
            },
            {
                "text" : "SAP송수신기록조회",
                "value": "SUP_12"
            }
        ]
    },
    {
        "text"       : "회계",
        "value"      : "ACCT_01",
        "items": [
            {
                "text" : "WEB-POS 사용자현황",
                "value": "ACCT_01"
            },
            {
                "text" : "WEB-POS 입금등록",
                "value": "ACCT_02"
            }
        ]
    }
]
于 2013-03-20T07:56:24.727 に答える