简体   繁体   English

在Aurelia打字稿中创建Kendo网格

[英]Creating Kendo Grid in Aurelia Typescript

I'm trying to use Kendo Grid in aurelia using typescript, but I keep getting a error when I try to initialize it. 我正在尝试使用打字稿在aurelia中使用Kendo Grid,但是在尝试对其进行初始化时,我总是收到错误消息。

/// <reference path="../../../../vendors/Kendoui/typescript/kendo.all.d.ts" />

export class Test
{
    attached()
    {
        $("#grid").kendoGrid();
    }
}

The error I'm getting is Unhandled rejection TypeError: $(...).kendoGrid is not a function 我得到的错误是Unhandled rejection TypeError: $(...).kendoGrid is not a function

Can someone please tell me what am I doing wrong?? 有人可以告诉我我在做什么错吗?

Edit: I have looked at using Aurelia-Kendo-bridge, but for performance reasons, I chose not to use it. 编辑:我已经看过使用Aurelia-Kendo-bridge,但是出于性能原因,我选择不使用它。

Thanks 谢谢

Take a look at the aurelia-kendoui-bridge project: https://github.com/aurelia-ui-toolkits/aurelia-kendoui-bridge This is an example from their component catalog: 看一下aurelia-kendoui-bridge项目: https : //github.com/aurelia-ui-toolkits/aurelia-kendoui-bridge这是其组件目录中的一个示例:

<template>
  <ak-grid k-data-source.bind="datasource"
          k-pageable.bind="{ refresh: true, pageSizes: true, buttonCount: 10 }"
          k-sortable.bind="true">
    <!-- Column definitions in HTML -->
    <ak-col k-title="Contact Name" k-field="ContactName">
      <ak-template>
        <!-- Column templates directly in your markup - where they belong! -->
        <div class="customer-photo" style="background-image: url(../content/web/Customers/${CustomerID}.jpg);"></div>
        <!-- Use Aurelia binding features like interpolation, value converters and binding behaviors -->
        <div class="customer-name">${ContactName}</div>
      </ak-template>
    </ak-col>
    <ak-col k-title="Contact Title" k-field="ContactTitle"></ak-col>
    <ak-col k-title="Company Name" k-field="CompanyName"></ak-col>
    <ak-col k-field="Country"></ak-col>
  </ak-grid>
</template>

And the ViewModel: 和ViewModel:

export class ViewModel {
  datasource = {
    type: 'odata',
    transport: {
      read: '//demos.telerik.com/kendo-ui/service/Northwind.svc/Customers'
    },
    pageSize: 5
  };
}

As per your original question, you're probably not importing Kendo. 按照您的原始问题,您可能不会导入Kendo。 Put an import statement at the top of your viewmodel file: 将import语句放在viewmodel文件的顶部:

import './path/to/kendo-ui.js';

How are you importing kendo? 您如何导入剑道? I wanted to use es2015 and systemJS bu later switched to importing the js files manually in my index page. 我想使用es2015和systemJS bu,后来切换为在索引页面中手动导入js文件。 I don't import all the widgets tough, to reduce size. 我并没有导入所有小部件,以减小尺寸。 Ofcourse doing it my way may mean that the kendo lib will be loaded upfront istead of when its required first. 当然,按照我的方式进行操作可能意味着kendo lib会被预先加载,而不是先加载它。

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

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