0

I'm trying to bind the JSON data object retrieved from the servlet.

$("#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"
                                }
                            }]
                          }
                      }
                  }
            })
        });

From the servlet, the JSON format is given as follows:

Hierarchy:

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

Example JSON:

Which ends up looking like:

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

Actual JSON I receive when calling the servlet directly:

[{"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"}]}]

I'd like to ask two questions:

  1. The servlet is not being called at all, even though I've explicitly declared the transport URL in the datasource.

  2. Is the above schema correct for declaring outer menu items and nesting items inside them?

1 Answer 1

2

The servlet is not being called because Kendo Menu does not define a DataSource for loading its content. BUT that doesn't mean that you cannot do it: yes, you can!

What you should do is:

  1. Define an empty menu.
  2. Define a DataSource.
  3. Trigger manually a read in the DataSource
  4. Append received data to the original menu.

The code:

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();

About your second question regarding the format of the JSON: replace subItemList by items, that's it. The entries on your JSON would look like:

[
    {
        "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"
            }
        ]
    }
]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.