- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在为数据表库使用很棒的插件 yadcf。我一直在 ASP.NET MVC 5 的 View 中使用它,没有任何问题。我们目前正在将应用程序迁移到 Angular 2,并使用 ASP.NET Web Api 提供数据。
我已经以最小的更改移动了代码,并通过将对数据表库的引用放入托管 Angular 应用程序的 index.html 页面上的脚本标记中,成功地使数据表正常工作。
然后,我从托管该表的组件中运行下面的数据表初始化代码。
但是,每当我尝试对 yadcf.init 执行相同操作时,我都会得到:
Uncaught (in promise): TypeError: Cannot read property 'replace' of undefined
它崩溃了。
ngOnInit(){
this.table = $('#studyList')
.DataTable({
serverSide: true,
responsive: true,
processing: true,
ajax: {........
........
}
.........
});
// runs fine to here and datatables works when the following is commented out
// but crashes as soon as i try and initialise yadcf from
// from within the component as follows.
yadcf.init(this.table,
[
{
column_number: 5,
filter_type: 'multi_select',
select_type: 'select2',
data: [
{ label: 'Included', value: 1 },
{ label: 'Excluded', value: 2 },
{ label: 'Insufficiently Screened', value: 4 }
]
}
]);
// This causes "Uncaught (in promise): TypeError:
// Cannot read property 'replace' of undefined" error
}
真的不想在新应用程序中失去过滤功能,因此将非常感谢您的帮助!
是否有一些关键可以让我缺少的 Angular 2 发挥作用?
看起来该错误实际上是由使用 jquery 3 引起的(见下文)。
最佳答案
我意识到这个错误与 Angular 完全无关(它只是被 Angular 重新抛出)!
我有一个不同版本的 jQuery(原始 MVC 应用程序中的2.2.4,但在索引中引用了3.1.0)。我的 Angular 应用程序的 html)
事实证明 yadcf 不能很好地与 jQuery 3 配合使用。
特别是在第一行内yadcf.init(oTable, options_arg, params)
函数进行以下分配。
function init(oTable, options_arg, params) {
var instance = oTable.settings()[0].oInstance;
// ......
// it is assumed that variable instance has a property called selector
// but this is not the case in jquery 3 so all occurrences of
// "instance.selector" later in the function are undefined.
// ......
$(document).data(instance.selector + "_filters_position", params.filters_position);
if ($(instance.selector).length === 1) {
setOptions(instance.selector, options_arg, params);
initAndBindTable(instance, instance.selector, 0, oTable);
} else {
for (i; i < $(instance.selector).length; i++) {
$.fn.dataTableExt.iApiIndex = i;
selector = instance.selector + ":eq(" + i + ")";
setOptions(instance.selector, options_arg, params);
initAndBindTable(instance, selector, i, oTable);
}
$.fn.dataTableExt.iApiIndex = 0;
}
}
这意味着 yadcf 尚未初始化,因此稍后调用 yadcf.exFilterColumn(table_arg, col_filter_arr, ajaxSource)
时,会抛出错误 Cannot read property 'replace' of undefined
.
关于jquery - 让 yadcf(用于数据表)在 Angular 2 (jQuery 3) 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39616477/
我有一个包含在列标记中的表(使用数据表框架)。我的意思是该列的内容如下所示: No No answer Yes 当我使用 yadcf 列过滤器并尝试在此选择中仅
我目前正在使用它: jQuery JavaScript 库 v2.2.4jQuery 用户界面 - v1.12.0 - 2016-07-08 我用下面的来初始化表 $(document
我正在使用 DataTables v 1.10.16 和 yadcf v 0.9.1,以及 range_date 过滤器。列标题正确显示日期的输入框,但是我遇到以下两个问题,使其无法使用: 1) da
我正在使用 jquery.dataTables.yadcf.js 和//cdn.datatables.net/1.10.6/js/jquery.dataTables.js 与 sAjaxSource
经历这个jsFiddle ,我想知道隐藏列的 YADCF 等效项,如标准 DataTables 的使用所示,启用隐藏列的过滤(DataTable 的目标似乎相当于 YADCF 的列号)。 下面是我想要
我需要在用图像创建的典型列上创建过滤器:每个字段都是具有这种格式的图像: 我在这里创建了一个 fiddle 示例:fiddle 一个解释: 虽然有 4 种不同的图像(黑色、红色、黄色和绿色),但只有
我正在尝试将“yadcf”过滤插件与数据表一起使用,并在调用yadcf函数的错误中获取“Uncaught TypeError:undefined is a function”错误。 我已验证插件已加载
有没有办法使用yadcf向过滤列添加类? 就目前而言,当我使用 yadcf 提供的选择框过滤表中的列时,我似乎无法显示该列已被过滤。 我想向列 添加一个类这样我就可以设置它的样式以向用户显示相应的列
有一个表,其中包含一些通过提供的 ajax 从服务器加载到 DataTable 的数据,还有用于在服务器端进行过滤的 yadcf。在其中一列中,我有 select2 框,在我只想看到预定义(从服务器加
请引用https://codepen.io/louking/pen/vWYqRz 当数据表的第 5 列和第 6 列可见时,exFilterColumn() 调用会按预期过滤行,但当这些列不可见时(如在
我正在尝试从 requirejs 配置切换到 webpack 配置,但无法使 yadcf 正常工作。 在我的 packages.json 中: { ... "dependencies": {
DataTable 初始化,给它服务器 url 位置 oTable = $('.entrys_table').DataTable({ "processing": true, "se
我有一个 UTF8 格式的 mysql 数据库,我之前已经正确输出了这些字母,但无法让我的 php 使用 ajax 进程对数据表执行此操作。我尝试了各种方法来让 UTF8 显示,包括更改 header
我正在使用 jQuery 插件 yadcf plugin 。首先,我定义了一个数组 all_serve_products = ["NOS","URS","NVS","NBS","CNS","NEFS"
我使用 DataTables 和 Yadcf 插件创建了一个表。它使用服务器端处理。我在第二列中添加了一个自动完成过滤器,并在服务器响应中添加了 yadcf_data_1 字段,但输入时没有任何反应。
我正在使用YADCF datatables 的插件我正在使用 exResetAllFilters 重置所有列过滤器,但它不起作用。 我做了一个example使用 Jsfiddle。使用Firebug我
在我的项目中,基于Datatables+YADCF,可以使用更多下拉菜单和Select2字段。所有数据均通过 Ajax 请求加载。好的,问题是: 在下拉列表中选择值后,是否可以在 Select2 字段
我不明白为什么 colvis 不适用于我的 table 。 我包含这些 css 和 js: 然后进行初始化 dom: 'Clfrtip' 所以我的代码是这样的: oTable = $('#exam
我在 jquery dataTables 上使用 yadcf 插件。我正在看yadcf-showcase.appspot.com/server_side_source.html并假设您单击第一列过滤器
我使用数据表,我想在我有数据前的日期之间进行搜索。 2018年2月3日至2019年3月4日在我的 html 中 From to 在我的js中,我使用带有ya
我是一名优秀的程序员,十分优秀!