- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我有一个基于 gridster 的布局,它将以一定数量的列和固定数量的图 block 开始。有没有办法在设置后更改列数? -- 例如从 3 列开始:
(tile1 | tile2 | tile3
tile4 | tile5 | tile6)
并将其更改为两列布局:
(tile1 | tile2
tile3 | tile4
tile5 | tile6)
更改将由用户交互驱动。
我试过使用类似的东西:
gridster = $("#gridster-container").gridster({
widget_margins: [30, 30],
widget_base_dimensions : [ 200, 170 ],
max_cols:numberOfColumns,
avoid_overlapped_widgets: true
}).data('gridster');
// user interaction
gridster.options.max_rows = 2;
gridster.init();
但这似乎行不通......
我尝试手动将 data-row
和 data-col
值更改为新位置,并调用了 init()(而不是调用 init)。
我什至尝试过更改 gridster 代码添加
// HACK
if (max_cols && max_cols < this.cols) {
this.cols = max_cols;
}
方法fn.generate_grid_and_stylesheet
(就在行之后:
if (max_cols && max_cols >= min_cols && max_cols < this.cols) {
this.cols = max_cols;
}
).
我可以使用这些选项中的任何一个让方 block 移动到正确的位置,但是随后的拖动行为是……奇怪的。
我已经设置了一个 jsfiddle ( http://jsfiddle.net/qT6qr/ ) 来解释我的意思(请原谅 gridster.min.js 在 fidddle 顶部的行中,我找不到可以用于它的 cdn ...)。
提前致谢
最佳答案
我只花了几个小时就遇到了 this piece of code .我只是把它放在一个 .js 文件中并做了:
var gr = $(elem).gridster(options).data('gridster');
// update options and then call this at a later point:
gr.resize_widget_dimensions(options);
然后它就成功了。
代码如下:
(function($) {
$.Gridster.generate_stylesheet = function(opts) {
var styles = '';
var max_size_x = this.options.max_size_x;
var max_rows = 0;
var max_cols = 0;
var i;
var rules;
opts || (opts = {});
opts.cols || (opts.cols = this.cols);
opts.rows || (opts.rows = this.rows);
opts.namespace || (opts.namespace = this.options.namespace);
opts.widget_base_dimensions || (opts.widget_base_dimensions = this.options.widget_base_dimensions);
opts.widget_margins || (opts.widget_margins = this.options.widget_margins);
opts.min_widget_width = (opts.widget_margins[0] * 2) +
opts.widget_base_dimensions[0];
opts.min_widget_height = (opts.widget_margins[1] * 2) +
opts.widget_base_dimensions[1];
/* generate CSS styles for cols */
for (i = opts.cols; i >= 0; i--) {
styles += (opts.namespace + ' [data-col="'+ (i + 1) + '"] { left:' +
((i * opts.widget_base_dimensions[0]) +
(i * opts.widget_margins[0]) +
((i + 1) * opts.widget_margins[0])) + 'px;} ');
}
/* generate CSS styles for rows */
for (i = opts.rows; i >= 0; i--) {
styles += (opts.namespace + ' [data-row="' + (i + 1) + '"] { top:' +
((i * opts.widget_base_dimensions[1]) +
(i * opts.widget_margins[1]) +
((i + 1) * opts.widget_margins[1]) ) + 'px;} ');
}
for (var y = 1; y <= opts.rows; y++) {
styles += (opts.namespace + ' [data-sizey="' + y + '"] { height:' +
(y * opts.widget_base_dimensions[1] +
(y - 1) * (opts.widget_margins[1] * 2)) + 'px;}');
}
for (var x = 1; x <= max_size_x; x++) {
styles += (opts.namespace + ' [data-sizex="' + x + '"] { width:' +
(x * opts.widget_base_dimensions[0] +
(x - 1) * (opts.widget_margins[0] * 2)) + 'px;}');
}
return this.add_style_tag(styles);
};
$.Gridster.add_style_tag = function(css) {
var d = document;
var tag = d.createElement('style');
tag.setAttribute('generated-from', 'gridster');
d.getElementsByTagName('head')[0].appendChild(tag);
tag.setAttribute('type', 'text/css');
if (tag.styleSheet) {
tag.styleSheet.cssText = css;
} else {
tag.appendChild(document.createTextNode(css));
}
return this;
};
$.Gridster.resize_widget_dimensions = function(options) {
if (options.widget_margins) {
this.options.widget_margins = options.widget_margins;
}
if (options.widget_base_dimensions) {
this.options.widget_base_dimensions = options.widget_base_dimensions;
}
this.min_widget_width = (this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0];
this.min_widget_height = (this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1];
var serializedGrid = this.serialize();
this.$widgets.each($.proxy(function(i, widget) {
var $widget = $(widget);
this.resize_widget($widget);
}, this));
this.generate_grid_and_stylesheet();
this.get_widgets_from_DOM();
this.set_dom_grid_height();
return false;
};
})(jQuery);
关于javascript - 如何更改 Gridster 中的列数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17741568/
您如何计算Oracle表中的列数? 最佳答案 SELECT count(*) FROM user_tab_columns WHERE table_name = 'FOO' 应该给你foo中的列数。您可
我有一个宽度为 100% 的 div,里面有大约 10 张图片,所有图片的宽度和大小都不同。我希望能够无缝地将这些图像彼此 float ,我已经做到了,但它们不会在屏幕上拉伸(stretch),它们都
请看下面的代码,表格应该根据下面selected id选项中选择的输入更改行数,但只读取select id的第一个值,行数不会根据选择,你能指出我代码中的错误吗? http://jsfiddle.ne
我需要一个可以在 3×3 和 4×4 之间切换的动态 gridlayout。我可以 setRowCount 和 setColumnCount 从 3 到4 但不是从 4 到 3。它会显示以下问题: C
这里有一个没有真正答案的类似问题:CSS columns bug — 5 column count only showing 4 (with images) 我正在使用 column-count 来显
我正在尝试找到一种方法来填充摊销时间表,如下所示。 我目前使用的公式是: =IF($B2=$1:$1,$A2/$C2," ") 但是,这仅填充了第一个点(“起点”),我想做的是根据摊销期抵消这一点。期
我运行以下代码: import cv2 import numpy as np img_file='pokemon.jpg' img=cv2.imread(img_file) # print tota
我正在使用 asp.net 和 vb。这里我将数据绑定(bind)到Gridview。该数据集有 5 条记录,3 列,并且 gridview 显示 5 条记录,3 列。但 Gridview.colum
我已经为我的数据库苦苦挣扎了一段时间,几乎不可能找到我的老师。我的代码如下: INSERT INTO `database28`.`activity` VALUES ("Stefan", 1.1.2.2
我有一个执行 SQL 命令的 python 脚本,并尝试将所有数据插入表中。问题是我有一个条目列表,例如: "Bob", "bob@gmail.com" "John", "john@gmail.com
有谁知道这是否可以通过 bootstrap mixins 来完成。 列(父级数) 像什么Neat有。 在 Neat the Columns 中,mixins 的工作方式如下 @mixin span-c
我有这样的网址:http://xn----7sbabhi8cwaajmue5o.xn--p1ai/cars/search/by_man_and_model?by_manufacturer=115 你可
使用 Bootstrap 3,我正在寻找一种网格布局,其中列宽在任何屏幕分辨率下都是固定的(比如 200 像素),但它们的数量取决于屏幕宽度。 换句话说,我知道列的宽度,但我不知道每行有多少列,因为这
public class SmallestColumn2{ public static void main(String[] args){ int [][] smallest
如果我只有 9 列,但我想将它们分散到 100% 的 div。如何做到这一点? NSW VIC QLD WA SA TAS ACT N
我想在这里更改列的顺序: #container { position: relative; width: 600px; } #column-wrapper { -webkit-
1、df=DataFrame([{‘A':'11','B':'12'},{‘A':'111','B':'121'},{‘A':'1111','B':'1211'}])
我想将csv文件形式的数据导入表中。[使用Oracle SQL Developer]。我有数百个文件,每个文件有大约50列。 从SQL * Loader Wiki(http://www.orafaq.
好吧,这对我来说似乎很基础,尽管我找不到任何关于如何实现它的信息。 假设我有某种 QGridLayout 包含相同大小的小部件。现在我想根据布局大小更新其行数/列数。 因此,例如在相对较宽的屏幕上它看
我在 https://cwiki.apache.org/confluence/display/Hive/Home 中找不到任何记录在案的限制。 我的猜测是行数或列数没有限制。文件大小受文件系统限制。通
我是一名优秀的程序员,十分优秀!