1

我卡在我想验证 Shift Day 的 Column 并将其限制为 Unique Data 的地方,我有一个 DropDownlist for Days 但我想在它已经在 Kendo Grid 中时显示一条消息。.

这是我的剑道网格

 $("#customerContactGrid").kendoGrid({
        scrollable: false,
        sortable: true,
        pageable: true,
        dataSource: {
            transport: {
                read: {
                    url: '/Client/LoadClientCustomerLocationContactList?clientCusLocId=' + clientCusLocId,
                    dataType: "json",
                    type: "POST"
                }

            },
            pageSize: 10
        },
        rowTemplate: kendo.template($("#clientContactTemplate").html().replace('k-alt', '')),
        altRowTemplate: kendo.template($("#clientContactTemplate").html())
    });

这是我的下拉列表

<span>
                @Html.DropDownList("ddlShiftDay", new SelectList(ViewBag.ShiftList, "ID", "Display_Value", clientCustomerShiftDay), "[Please Select]",
          new Dictionary<string, object>
                {
                    {"class","validate[required] inputLong"}
                })
            </span>

这是我的控制器:

private void GetShiftList()
        {
            // get status list from lookups
            var shiftlist = (from a in db.Lookups
                             where a.Domain == "AVAILABLEDAY"
                             select a).ToList();
            // add status list to a data container be called in view
            ViewBag.ShiftList = shiftlist;
        }

希望有人可以帮助我显示一条消息,提示用户是否输入了网格列中已经存在的数据

4

2 回答 2

1

你的问题有几件事要理解

您正在使用的剑道 UI 由 ajax 调用填充

url: '/Client/LoadClientCustomerLocationContactList?clientCusLocId=' + clientCusLocId,
dataType: "json",
type: "POST"

这又由服务器端方法填充。

现在下拉选择是一个客户端事件,它再次在服务器上触发一个新的 AJAX 调用。

要比较数据,您有两种方法:

no.1 在服务器上保存上一个 ajax 调用的结果,并在服务器本身上比较下一个 AJAX 调用的结果,如果数据是公共的,则返回 null

no.2 在接收到下拉事件的 ajax 调用结果时,使用客户端脚本进行比较。

更新

方法#2的东西可能会像

$(".dayDropDown").change(function(){
        
           var str = $( this ).text();
           var tableData = $("#customerContactGrid").html();
           if(tableData.indexOf(str) != -1){  // find the day in table data
                    //True condition statements
           }else{
                    //False condition statements
           }
            
});
于 2013-09-13T03:57:05.243 回答
0

我使用此功能导出网格:

function ExportGrid(gridName, exportTitle, exportFormat) {

        showWaitIndicator(true);
        var grid = $('#' + gridName).data('kendoGrid');
        var exportGridRequest = {            
            title: exportTitle,
            columns: JSON.stringify(grid.columns),
            data:JSON.stringify(grid.dataSource.data().toJSON()),
            format:exportFormat
        };
        $.ajax({
            type: "POST",
            url: '@Url.Action("ExportCreate","Grid")',
            datatype: "json",
            traditional: true,
            data: exportGridRequest,
            success: function (data, status, jqXHR) {
                showWaitIndicator(false);
                if (data.FileIdentifier != null) {

                    window.location.href='@Url.Action("DownloadFile")?fileIdentifier='+data.FileIdentifier;
               } else
                   alert(jqxhr.responseText);               
            },
            error: function (xhr, status, error) {
                showWaitIndicator(false);
                result = false;
                var msg = JSON.parse(xhr.responseText);
                var err = msg.Message;
                alert(xhr.responseText);
            }
        });

    }

data 属性不是轻量级的,因为它包含网格中的所有数据,但除非您进行一些花哨的搜索,否则您可以获得一个网格实例:

var grid = $('#' + gridName).data('kendoGrid');
var columns= JSON.stringify(grid.columns);
var data=JSON.stringify(grid.dataSource.data().toJSON());

据我所知,您的搜索需要使用列和数据(分组很棘手)。通过循环 div 客户端的所有元素可能有一种更快的方法。

于 2013-09-13T03:55:27.237 回答