Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 本地存储不';不要刷新网格_Jquery_Grid_Local Storage_Kendo Ui - Fatal编程技术网

Jquery 本地存储不';不要刷新网格

Jquery 本地存储不';不要刷新网格,jquery,grid,local-storage,kendo-ui,Jquery,Grid,Local Storage,Kendo Ui,我解决不了这个问题 这是我的密码 var selectedID = ""; var selectedIDPremise = ""; var PremisesGrid = ""; var PremisesGrid2 = ""; var selectedIDPremise2 = ""; //var selectedOD2 = ""; var nova = ""; $(document).ready(function () {

我解决不了这个问题

这是我的密码

var selectedID = "";
    var selectedIDPremise = "";
    var PremisesGrid = "";
    var PremisesGrid2 = "";
    var selectedIDPremise2 = "";
    //var selectedOD2 = "";
    var nova = "";

    $(document).ready(function () {



        $("#routes").kendoDropDownList({
            dataTextField: "Name",
            dataValueField: "Id",
            dataSource: {
                type: "application/jsonp",
                transport: {
                    read: {
                        url: "http://" + servername + "/uBillingServices/Administration/Administration.svc/getRoute",
                        dataType: "json",
                        data: {
                            ID: 0
                        }
                    }
                }
            },
            select: onSelect
        });

        //nova = PremisesGrid2.getKendoDropDownList().dataSource.transport.options.read.data.Route_ID;

        function onSelect(e) {

            //$.getJSON("http://" + servername + "/uBillingServices/Administration/Administration.svc/getRoute", { ID: nova }, function (json) { });
            window.localStorage.setItem("Nova", "");
            nova = this.dataItem(e.item.index());
            window.localStorage.setItem("Nova", nova.ID);
            PremisesGrid2.getKendoGrid().dataSource.read();
            //nova = PremisesGrid2.getKendoDropDownList().dataSource.transport.options.read.data.Route_ID;
            // var data = [{}];
            //PremisesGrid2.getKendoGrid().dataSource.data(data)
            for (var i = 0; i < 3000; i++) {
                if (i == 2999) {
                    PremisesGrid2.getKendoGrid().dataSource.read();
                }
            }

        }
            PremisesGrid2 = $("#assignedRoute").kendoGrid({
                //dataTextField: "Name",
                //dataValueField: "Id",
                dataSource: {
                    type: "application/jsonp",
                    transport: {
                        read:
                                {
                                    url: "http://" + servername + "/uBillingServices/Premise/Premise.svc/GetAllPremisesByRoute",
                                    dataType: "json",
                                    data: {
                                        Route_ID: window.localStorage.getItem("Nova"),
                                        UserName: userName,
                                        WorkStation: workStation

                                    }
                                }
                    },
                    schema: {
                        model: {
                            fields: {
                                ID: { type: "string" },
                                PostalCode: { type: "string" },
                                Latitude: { type: "string" },
                                Longitude: { type: "string" },
                                IsMember: { type: "string" }

                            }
                        }
                    }
                },
                change: function (arg) {

                    myIndex = this.select().index();
                    var PremisesRow = this.select();

                },
                dataBound: function (e) {

                    row = e.sender.tbody.find(">tr:not(.k-grouping-row)").eq(0);
                    if (row.length == 0) {
                        e.sender.select(e.sender.tbody.find(">tr:first"));
                    }
                    else {
                        e.sender.select(row);
                    }
                },
                selectable: true,
                scrollable: true,
                filterable: true,
                groupable: false,
                sortable: {
                    mode: "single",
                    allowUnsort: false
                },
                height: 330,

                columns: [
                    { field: "PostalCode", title: "Assigned Route" }
                    ]//, width: "100px"
            });
var selectedID=“”;
var selectedpremise=“”;
var PremisesGrid=“”;
var PremisesGrid2=“”;
var selectedpremise2=“”;
//var selectedOD2=“”;
var nova=“”;
$(文档).ready(函数(){
$(“#路线”)。kendoDropDownList({
dataTextField:“名称”,
dataValueField:“Id”,
数据源:{
类型:“应用程序/jsonp”,
运输:{
阅读:{
url:“http://“+servername+”/uBillingServices/Administration/Administration.svc/getRoute”,
数据类型:“json”,
数据:{
身份证号码:0
}
}
}
},
选择:onSelect
});
//nova=PremisesGrid2.getKendoDropDownList().dataSource.transport.options.read.data.Route_ID;
功能选择(e){
//$.getJSON(“http://“+servername+”/uBillingServices/Administration/Administration.svc/getRoute”,{ID:nova},函数(json){});
window.localStorage.setItem(“Nova”和“”);
nova=this.dataItem(e.item.index());
window.localStorage.setItem(“Nova”,Nova.ID);
PremisesGrid2.getKendoGrid().dataSource.read();
//nova=PremisesGrid2.getKendoDropDownList().dataSource.transport.options.read.data.Route_ID;
//变量数据=[{}];
//PremisesGrid2.getKendoGrid().dataSource.data(数据)
对于(变量i=0;i<3000;i++){
如果(i==2999){
PremisesGrid2.getKendoGrid().dataSource.read();
}
}
}
PremisesGrid2=$(“#分配路线”)。肯多格里德({
//dataTextField:“名称”,
//dataValueField:“Id”,
数据源:{
类型:“应用程序/jsonp”,
运输:{
阅读:
{
url:“http://“+servername+”/uBillingServices/Premise/Premise.svc/GetAllPremisesByRoute”,
数据类型:“json”,
数据:{
路由ID:window.localStorage.getItem(“Nova”),
用户名:用户名,
工作站:工作站
}
}
},
模式:{
型号:{
字段:{
ID:{type:“string”},
PostalCode:{type:“string”},
纬度:{type:“string”},
经度:{type:“string”},
IsMember:{type:“string”}
}
}
}
},
更改:函数(arg){
myIndex=this.select().index();
var PremisesRow=this.select();
},
数据绑定:函数(e){
row=e.sender.tbody.find(“>tr:not(.k-grouping-row)”).eq(0);
if(row.length==0){
e、 sender.select(e.sender.tbody.find(“>tr:first”);
}
否则{
e、 发件人。选择(行);
}
},
是的,
可滚动:对,
可过滤:正确,
分组:false,
可排序:{
模式:“单身”,
allowUnsort:错误
},
身高:330,
栏目:[
{字段:“PostalCode”,标题:“分配的路线”}
]//,宽度:“100px”
});
localStorage工作正常(在资源中它会更改),但当我选择另一个Reon(从下拉列表中)时,它不会刷新网格,当我刷新页面时,它会显示我选择的最后一个Reon


有人能告诉我问题出在哪里吗?谢谢,有几个问题:

  • ID
    ID
    之间的混淆
  • transport.read.data
    中的
    data
    定义需要是一个函数
  • 关于1.在
    DropDownList
    定义中,您说
    dataValueField:“Id”
    ,但在
    onSelect中,您使用:
    window.localStorage.setItem(“Nova”,Nova.Id);

    关于2.将
    数据
    的定义从
    对象
    更改为
    函数
    。方法如下:

    data    : function () {
        return {
            {
                Route_ID: window.localStorage.getItem("Nova"),
                UserName: userName,
                WorkStation: workStation
            }
        }
    }
    

    请制作一个小提琴或链接到原始的。我甚至不明白是什么问题,也不愿意阅读整个代码来理解它。我希望这会有帮助,所以你可以帮助我:)我改变了你说的一切,但仍然什么也没做。在第一次加载时,当我在开发人员工具/资源中查看“Nova”的值时,它用最后一个选择窗口的数据源填充网格。localStorage.getItem(“Nova”)当我在下拉列表中更改它时会发生更改,但它不会刷新网格…当我刷新整个页面时,网格的数据源与上一个选择的项的数据源表单DropDownList是否检查
    datasource.read()
    实际上是在向服务器发送请求吗?在
    数据
    函数中添加一个跟踪,显示
    window.localStorage.getItem(“Nova”)
    实际上拥有
    下拉列表的
    Id
    。最后,您可以尝试在
    传输中禁用
    缓存
    。阅读
    确保KendoUI发送请求。最后一件事,哪个版本