我对FuelUX很陌生,所以我试图让它工作起来,根据提供的示例:
require(['jquery','data.js', 'datasource.js', 'fuelux/all'], function ($, sampleData, StaticDataSource) {
var dataSource = new StaticDataSource({
columns: [{property:"memberid",label:"LidId",sortable:true},{property:"name",label:"Naam",sortable:true},{property:"age",label:"Leeftijd",sortable:true}],
data: sampleData.memberdata,
delay: 250
});
$('#MyGrid').datagrid({
dataSource: dataSource,
stretchHeight: true
});
});
});将此作为数据:
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else {
root.sampleData = factory();
}
}(this, function () {
return {
"memberdata": [{
"memberid": 103,
"name": "Laurens Natzijl",
"age": "25"
}, {
"memberid": 104,
"name": "Sandra Snoek",
"age": "25"
}, {
"memberid": 105,
"name": "Jacob Kort",
"age": "25"
}, {
"memberid": 106,
"name": "Erik Blokker",
"age": "25"
}, {
"memberid": 107,
"name": "Jacco Ruigewaard",
"age":"25"
},{ /* etc */ }]
}
}));我没有控制台错误,没有丢失的包含。每件事都很好--甚至看起来像是在装货。除了在数据集中没有显示任何内容,而是“0项”。
有什么建议吗?我想我做了所有的例子.
编辑: 14:33 (阿姆斯特丹)当我把它放在控制台中时,似乎有不同之处:
My页面:
require(['jquery','data.js','datasource.js', 'fuelux/all'], function ($, sampleData, StaticDataSource) {
var dataSource = new StaticDataSource({
columns: [{property:"memberid",label:"LidId",sortable:true},{property:"name",label:"Naam",sortable:true},{property:"age",label:"Leeftijd",sortable:true}],
data: sampleData.memberdata,
delay: 250
});
console.debug(dataSource);
});控制台中的第1行:
function localRequire(deps, callback, errback) { /* etc */ }控制台中的第2行:
StaticDataSource {_formatter: undefined, _columns: Array[3], _delay: 250, _data: Array[25], columns: function…}FuelUX示例:
require(['jquery', 'sample/data', 'sample/datasource', 'sample/datasourceTree', 'fuelux/all'], function ($, sampleData, StaticDataSource, DataSourceTree) {
var dataSource = new StaticDataSource({
columns: [{property: 'toponymName',label: 'Name',sortable: true}, {property: 'countrycode',label: 'Country',sortable: true}, {property: 'population',label: 'Population',sortable: true}, {property: 'fcodeName',label: 'Type',sortable: true}],
data: sampleData.geonames,
delay: 250
});
console.debug(dataSource);
});控制台中的第1行:
StaticDataSource {_formatter: undefined, _columns: Array[4], _delay: 250, _data: Array[146], columns: function…}控制台中的第2行:
function (deps, callback, errback, relMap) { /* etc */ }也许这会帮助你帮助我:)
发布于 2013-05-08 14:03:56
我没有看到提供有限答案所需的所有信息。真正的魔力是datasource.js文件(您还没有提供)。
我认为演示所有必要部分的一个更简单的方法是将显示正在使用的数据和所有必需的数据的JSFiddle组合在一起。
Link to JSFiddle of Fuel UX Datagrid sample with your data
Alexander,这个工具的作者,也写了一个使用dataGrid DailyJS Fuel UX DataGrid的有价值的例子。
// DataSource Constructor
var StaticDataSource = function( options ) {
this._columns = options.columns;
this._formatter = options.formatter;
this._data = options.data;
this._delay = options.delay;
};
StaticDataSource.prototype = {
columns: function() {
return this._columns
},
data: function( options, callback ) {
var self = this;
var data = $.extend(true, [], self._data);
// SEARCHING
if (options.search) {
data = _.filter(data, function (item) {
for (var prop in item) {
if (!item.hasOwnProperty(prop)) continue;
if (~item[prop].toString().toLowerCase().indexOf(options.search.toLowerCase())) return true;
}
return false;
});
}
var count = data.length;
// SORTING
if (options.sortProperty) {
data = _.sortBy(data, options.sortProperty);
if (options.sortDirection === 'desc') data.reverse();
}
// PAGING
var startIndex = options.pageIndex * options.pageSize;
var endIndex = startIndex + options.pageSize;
var end = (endIndex > count) ? count : endIndex;
var pages = Math.ceil(count / options.pageSize);
var page = options.pageIndex + 1;
var start = startIndex + 1;
data = data.slice(startIndex, endIndex);
if (self._formatter) self._formatter(data);
callback({ data: data, start: 0, end: 0, count: 0, pages: 0, page: 0 });
}
};如果您要提供您的标记和您的"datasource.js“文件所包含的内容,我可能会进一步帮助您。
我认为这个演示提供了很多关于你可能不理解的部分的信息。
发布于 2013-05-22 00:33:36
再加上造物专家的回答:
在他的JSFiddle示例中,分页被破坏了。若要修复它,请更改以下行:
callback({ data: data, start: start, end: end, count: count, pages: pages, page: page });发布于 2013-12-16 15:51:19
当我试图与Django融合时,我也遇到了同样的问题。我认为问题就在这条线上:
要求(‘jquery’,'data.js',‘datource.js’,'fuelux/all',函数($,sampleData,StaticDataSource) {
我无法指定文件扩展名,当使用"data.js“时,我的IDE (py魅力)将标记为"red",因此它需要保持没有扩展名,例如”示例/数据“。
最后,我要做的是从/var/www/html的普通Apache设置中从github下载完整的fuelux目录( no,以避免静态文件出现URL.py问题),一切都使用它们的示例。以下是让您开始工作的步骤:
cd /var/www/html git克隆https://github.com/ExactTarget/fuelux.git,您将得到/var/www/html/ fuelux /中的fuelux。
在浏览器中,导航到:http://foo.com/fuelux/index.html (假设默认文档根目录为/var/www/html )
祝好运!
https://stackoverflow.com/questions/16440292
复制相似问题