简体   繁体   English

Kendo UI网格自定义数据源URL

[英]Kendo UI grid custom datasource URL

I have a comboBox called clientCCBox, I need a javascript that retrieves the selected option value, wich will be the client id, and then passes it on the kendo grid datasource read property as follow: 我有一个名为clientCCBox的comboBox,我需要一个javascript来检索所选的选项值,它将是客户端ID,然后将它传递给kendo网格数据源读取属性,如下所示:

<kendo:dataSource-transport-read url="/read.html?*clientID*"/>

I've been trying to use this js snippet to recover the selected value; 我一直在尝试使用这个js片段来恢复所选的值; the document write is there to visually see if it actually retrieved the value, but it displays nothing. 文档写在那里可视地查看它是否实际检索到了值,但它什么也没显示。 How would I once I get the clientID use it in HTML? 一旦我获得clientID在HTML中使用它,我将如何?

<script> 
    function onSelect(e){
        var clientId = clientCCBox.value();   
        document.write(clienteId);
    }
</script>

If I do manage to pass clientID on the querystring, the following code on the controller would return a list and populate the grid right? 如果我设法在查询字符串上传递clientID,控制器上的以下代码将返回一个列表并正确填充网格?

@RequestMapping(value = "/read.html*")
public @ResponseBody List<Workers> read(HttpServletRequest request) {
    return workerDAO.listWorker(Integer.parseInt(request.getQueryString()));
}

You can define your additional parameters using parameterMap attribute in kendo:dataSource-transport tag. 您可以使用kendo:dataSource-transport标记中的parameterMap属性定义其他参数。

Example: 例:

<kendo:dataSource-transport parameterMap="additionalParameters">
    <kendo:dataSource-transport-read url="/ListBeer" type="GET" contentType="application/json"/>
</kendo:dataSource-transport>

Where additionalParameters is: additionalParameters是:

<script type="text/javascript">
    var theId = "xyz";

    function additionalParameters(data, type) {
        if (type === "read") {
            return "id=" + theId;
        }
        return data;
    }
</script>

Here, I would be loading data from the following url /ListBeer?id=xyz where xyz is the value of theId . 在这里,我将从以下url /ListBeer?id=xyz加载数据/ListBeer?id=xyz其中xyztheId的值。

You can also send more than one parameter: 您还可以发送多个参数:

function additionalParameters(data, type) {
    if (type === "read") {
        return "id=" + data + "&param=" + JSON.stringify(data);
    }
    return "param= "+ JSON.stringify(data);
}

Use the "Data" event on the read action parameter for the drop down to specify dynamic javascript parameters to the drop down. 使用下拉列表的读取操作参数上的“数据”事件为下拉列表指定动态javascript参数。 Note the exact syntax for the .Read method. 请注意.Read方法的确切语法。 Often you see the syntax .Read("ActionName", "ControllerName") but we want the other overloaded version of .Read: 通常你会看到语法.Read(“ActionName”,“ControllerName”)但我们想要其他重载版本的.Read:

.DataSource(data => data.Read(read => read.Action("GetDropDownValues", "Quote").Data("getCriteria")))

function getCriteria() {
    return {
        id: "put value here",
        anotherParameter: 55
    };
}

you need to put the client id in the data field of the transport. 您需要将客户端ID放在传输的数据字段中。

Look at the following link. 请看以下链接。

http://docs.kendoui.com/api/framework/datasource#transportcreatedata-objectstringfunction http://docs.kendoui.c​​om/api/framework/datasource#transportcreatedata-objectstringfunction

this is part of jquery not kendo ui 这是jquery不是kendo ui的一部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM