将json文件加载到ListView的数据源中

将json文件加载到ListView的数据源中,listview,kendo-ui,datasource,Listview,Kendo Ui,Datasource,我想从json文件加载数据,以便在viewlist中使用它 <script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template"> <h3>#:ProductName#</h3> </script> <script> function mobileListViewLocalFiltering() { var dataSource = new

我想从json文件加载数据,以便在viewlist中使用它

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>
在我的index.html中只有一个div容器

<div id="listA"></div>
<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>
}

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>
我真的很难做到这一点,我尝试了网格和其他小部件,但我无法将jason文件的内容加载到小部件中,我不知道错误在哪里。是数据源吗?模板

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

谢谢你的帮助

我想你可以用这个例子试试

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

#:ProductName#
函数mobileListViewLocalFiltering(){
var dataSource=new kendo.data.dataSource({
数据:产品,
模式:{
型号:{
字段:{
产品名称:{type:“string”},
单价:{type:“number”},
UnitsInStock:{type:“number”},
中断:{type:“boolean”}
}
}
}
});
$(“#本地可筛选列表视图”).kendoMobileListView({
数据源:数据源,
模板:$(“#移动列表视图筛选模板”).text(),
可过滤:{
字段:“产品名称”,
接线员:“开始使用”
},
virtualViewSize:100,//由于数据源没有(也不应该)设置分页,因此需要此配置来确定显示的项目。
Endlesscroll:对
});
}
var app=new kendo.mobile.Application(document.body);

我想你可以用这个例子试试

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

#:ProductName#
函数mobileListViewLocalFiltering(){
var dataSource=new kendo.data.dataSource({
数据:产品,
模式:{
型号:{
字段:{
产品名称:{type:“string”},
单价:{type:“number”},
UnitsInStock:{type:“number”},
中断:{type:“boolean”}
}
}
}
});
$(“#本地可筛选列表视图”).kendoMobileListView({
数据源:数据源,
模板:$(“#移动列表视图筛选模板”).text(),
可过滤:{
字段:“产品名称”,
接线员:“开始使用”
},
virtualViewSize:100,//由于数据源没有(也不应该)设置分页,因此需要此配置来确定显示的项目。
Endlesscroll:对
});
}
var app=new kendo.mobile.Application(document.body);

我想你可以用这个例子试试

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

#:ProductName#
函数mobileListViewLocalFiltering(){
var dataSource=new kendo.data.dataSource({
数据:产品,
模式:{
型号:{
字段:{
产品名称:{type:“string”},
单价:{type:“number”},
UnitsInStock:{type:“number”},
中断:{type:“boolean”}
}
}
}
});
$(“#本地可筛选列表视图”).kendoMobileListView({
数据源:数据源,
模板:$(“#移动列表视图筛选模板”).text(),
可过滤:{
字段:“产品名称”,
接线员:“开始使用”
},
virtualViewSize:100,//由于数据源没有(也不应该)设置分页,因此需要此配置来确定显示的项目。
Endlesscroll:对
});
}
var app=new kendo.mobile.Application(document.body);

我想你可以用这个例子试试

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>

#:ProductName#
函数mobileListViewLocalFiltering(){
var dataSource=new kendo.data.dataSource({
数据:产品,
模式:{
型号:{
字段:{
产品名称:{type:“string”},
单价:{type:“number”},
UnitsInStock:{type:“number”},
中断:{type:“boolean”}
}
}
}
});
$(“#本地可筛选列表视图”).kendoMobileListView({
数据源:数据源,
模板:$(“#移动列表视图筛选模板”).text(),
可过滤:{
字段:“产品名称”,
接线员:“开始使用”
},
virtualViewSize:100,//由于数据源没有(也不应该)设置分页,因此需要此配置来确定显示的项目。
Endlesscroll:对
});
}
var app=new kendo.mobile.Application(document.body);

见鬼,我知道了。。。这是IIS的问题-扩展json未知。。。更改网络配置修复了它。

见鬼,我找到了。。。这是IIS的问题-扩展json未知。。。更改网络配置修复了它。

见鬼,我找到了。。。这是IIS的问题-扩展json未知。。。更改网络配置修复了它。

见鬼,我找到了。。。这是IIS的问题-扩展json未知。。。更改网络配置修复了它。

我从telerik页面知道这个示例。我已经看到了很多例子和其他类似主题的帖子,但是在这里没有任何帮助。我从telerik页面知道这个例子。我已经看到了很多例子和其他类似主题的帖子,但是在这里没有任何帮助。我从telerik页面知道这个例子。我已经看到了很多例子和其他类似主题的帖子,但是在这里没有任何帮助。我从telerik页面知道这个例子。我已经看到了许多例子和其他主题类似的线程,但是在这里没有任何东西可以帮助我解决这个问题。
<script type="text/x-kendo-tmpl" id="mobile-listview-filtering-template">
    <h3>#:ProductName#</h3>
</script>

<script>
  function mobileListViewLocalFiltering() {
    var dataSource = new kendo.data.DataSource({
      data: products,
      schema: {
        model: {
          fields: {
            ProductName: { type: "string" },
            UnitPrice: { type: "number" },
            UnitsInStock: { type: "number" },
            Discontinued: { type: "boolean" }
          }
        }
      }
    });

    $("#local-filterable-listview").kendoMobileListView({
      dataSource: dataSource,
      template: $("#mobile-listview-filtering-template").text(),
      filterable: {
        field: "ProductName",
        operator: "startswith"
      },
      virtualViewSize: 100, // this configuration is needed to determine the items displayed, since the datasource does not (and should not) have paging set.
      endlessScroll: true
    });
  }
</script>
<script>
  var app = new kendo.mobile.Application(document.body);
</script>