在Kendo UI Grid中显示JSON数据

时间:2015-04-21 17:59:55

标签: javascript json kendo-grid

您好我已经创建了一个html,java脚本。我能够将json数据绑定到kendo UI下拉列表,并能够在Html页面上显示该列表。当选择列表中的任何数据时,我能够检索所选值。现在我尝试用kendo ui网格替换下拉列表,并希望检索选定的行单元格值。下面是kendo下拉列表的代码。帮助将受到高度赞赏。

HTML文件

     <table style="padding-top: 20px; padding-left: 10px; display: table;" id="selectAccountTable">        <tbody>
        <tr>
            <td>Existing Account Found</td>
        </tr>
         <tr>
            <td>
              <!--need to display kendo grid UI , kendo drop down  is created at this input 
                <input id="accountSelect" style="width: 350px;">
            </td>
        </tr>

    

     JavaScript code
      function DisplayActiveAccounts(res)
      {
        var accounts = [];
        var response = $.parseJSON(res);
        for (var idx = 0; idx < response.length; idx++)
        {
        accounts.push({ 'name': response[idx].Name, 'id':  response[idx].Id, 'code': 
           response[idx].Code,'city':response[idx].City,'state':response[idx].State,'ce':response[idx].CE});

        }

        $('#selectAccountTable').show();
        selectAccountVisible = true;
       //need to create kendo ui grid instead of kendo ui drop down list
        $('#accountSelect').kendoDropDownList({
            dataTextField: "name",
            dataValueField: "accountid",

            dataSource: accounts

        });
    }

     function _okClick()
              {
              if (closeWindow) {
            //If the account select table is visible pass back selected  account code
            //need to retrieve the selected row values in returnValues variable
            if (selectAccountVisible) {
                var dropDownSelect = $("#accountSelect").data  ("kendoDropDownList");
                var listData = dropDownSelect.dataSource;
                //Get data from selecte value in drop down
                var selectedData = listData._data.filter(function (account)          { return account.id == dropDownSelect.value() });
                var returnValues = { testID: selectedData[0].id, testCode: selectedData[0].code };

            }
            closeWindow();
            }
             }

0 个答案:

没有答案