- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
jqgrid 是固定宽度的。
我尝试了下面基于 How to change column name in column chooser pop up in jqgrid? 的代码
创建列切换器。打开或关闭某些列后,网格宽度更改为全屏。如何解决此问题,以便网格在列菜单中选择列后保持其宽度?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>https://stackoverflow.com/q/27617764/315935</title>
<meta name="author" content="Oleg Kiriljuk">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/redmond/jquery-ui.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://cdn.jsdelivr.net/free-jqgrid/4.8.0/css/ui.jqgrid.css">
<link rel="stylesheet" href="http://cdn.jsdelivr.net/free-jqgrid/4.8.0/plugins/ui.multiselect.css">
<style>
html, body { font-size: 75%; }
.ui-datepicker select.ui-datepicker-year,
.ui-datepicker select.ui-datepicker-month {
color: black
}
.ui-jqgrid .ui-pg-table .ui-pg-button.ui-state-active { margin: 1px; font-weight: normal; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="http://cdn.jsdelivr.net/free-jqgrid/4.8.0/js/i18n/grid.locale-en.js"></script>
<script>
$.jgrid = $.jgrid || {};
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<!--<script src="../jqGrid/js/jquery.jqGrid.src.js"></script>-->
<script src="http://cdn.jsdelivr.net/free-jqgrid/4.8.0/js/jquery.jqgrid.src.js"></script>
<script src="http://rawgit.com/free-jqgrid/jqGrid/master/plugins/jquery.jqgrid.showhidecolumnmenu.js"></script>
<script src="http://rawgit.com/free-jqgrid/jqGrid/master/plugins/jquery.contextmenu-ui.js"></script>
<script src="http://rawgit.com/free-jqgrid/jqGrid/master/plugins/jquery.createcontexmenufromnavigatorbuttons.js"></script>
<script src="http://cdn.jsdelivr.net/free-jqgrid/4.8.0/plugins/ui.multiselect.js"></script>
<script>
//<![CDATA[
/*global $ */
/*jslint browser: true */
$(function () {
"use strict";
var mydata = [
{ id: "10", invdate: "2007-10-01", name: "test", note: "note", amount: "", tax: "", closed: true, ship_via: "TN", total: "" },
{ id: "20", invdate: "2007-10-02", name: "test2", note: "note2", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
{ id: "30", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", closed: false, ship_via: "FE", total: "430.00" },
{ id: "40", invdate: "2007-10-04", name: "test4", note: "note4", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00" },
{ id: "50", invdate: "2007-10-31", name: "test5", note: "note5", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
{ id: "60", invdate: "2007-09-06", name: "test6", note: "note6", amount: "400.00", tax: "30.00", closed: false, ship_via: "FE", total: "430.00" },
{ id: "70", invdate: "2007-10-04", name: "test7", note: "note7", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00" },
{ id: "80", invdate: "2007-10-03", name: "test8", note: "note8", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
{ id: "90", invdate: "2007-09-01", name: "test9", note: "note9", amount: "400.00", tax: "30.00", closed: false, ship_via: "TN", total: "430.00" },
{ id: "100", invdate: "2007-09-08", name: "test10", note: "note10", amount: "500.00", tax: "30.00", closed: true, ship_via: "TN", total: "530.00" },
{ id: "110", invdate: "2007-09-08", name: "test11", note: "note11", amount: "500.00", tax: "30.00", closed: false, ship_via: "FE", total: "530.00" },
{ id: "120", invdate: "2007-09-10", name: "test12", note: "note12", amount: "500.00", tax: "30.00", closed: false, ship_via: "FE", total: "530.00" }
],
$grid = $("#grid"),
initDateEdit = function (elem) {
$(elem).datepicker({
dateFormat: "dd-M-yy",
autoSize: true,
changeYear: true,
changeMonth: true,
showButtonPanel: true,
showWeek: true
});
},
initDateSearch = function (elem) {
setTimeout(function () {
initDateEdit(elem);
}, 100);
};
$grid.jqGrid({
data: mydata,
colNames: ["", "Client", "Date", "Amount", "Tax", "Total", "Closed", "Shipped via", "Notes"],
colModel: [
{ name: "act", template: "actions" },
{ name: "name", align: "center", width: 92, editrules: {required: true} },
{ name: "invdate", width: 72, align: "center", sorttype: "date", frozen: true,
formatter: "date", formatoptions: { newformat: "d-M-Y", reformatAfterEdit: true }, datefmt: "d-M-Y",
editoptions: { dataInit: initDateEdit },
searchoptions: { sopt: ["eq", "ne", "lt", "le", "gt", "ge"], dataInit: initDateSearch } },
{ name: "amount", width: 56, template: "number", hidden: true },
{ name: "tax", width: 35, template: "number", autoResizableMinColSize: 40, hidden: true },
{ name: "total", width: 43, template: "number", hidden: true },
{ name: "closed", width: 49, template: "booleanCheckboxFa" },
{ name: "ship_via", width: 76, align: "center", formatter: "select",
edittype: "select", editoptions: { value: "FE:FedEx;TN:TNT;IN:Intim", defaultValue: "IN" },
stype: "select", searchoptions: { sopt: ["eq", "ne"], value: ":Any;FE:FedEx;TN:TNT;IN:IN" } },
{ name: "note", width: 3343, edittype: "textarea", sortable: false }
],
cmTemplate: { editable: true, autoResizable: true },
iconSet: "fontAwesome",
rowNum: 10,
autoResizing: { compact: true },
rowList: [5, 10, 20, "10000:All"],
//pagerpos: "right",
//viewrecords: true,
//pgbuttons: false,
//pginput: false,
//width: 390,
toppager: true,
rownumbers: true,
sortname: "invdate",
sortorder: "desc",
navOptions: {
position: "center",
addtext: "Add",
edittext: "Edit",
deltext: "Delete",
searchtext: "Search",
refreshtext: "Reload",
viewtext: "View",
savetext: "Save",
canceltext: "Cancel",
iconsOverText: true
},
caption: "Demonstration how to make full width navigator bar",
width: '100px',
}).jqGrid("navGrid", {view: true})
.jqGrid("inlineNav")
//.jqGrid("filterToolbar")
// .jqGrid("gridResize")
.jqGrid("showHideColumnMenu")
.jqGrid("createContexMenuFromNavigatorButtons", $grid.jqGrid("getGridParam", "pager"));
$grid.jqGrid('setGridWidth', 200, false);
var autoedit = true;
$grid.jqGrid("navButtonAdd", "#grid_toppager", {
buttonicon: "fa-star",
caption: "Toggle",
id: "AutoEdit",
title: "Toggle autoedit",
onClickButton: function (options, e) {
var $me = $(e.currentTarget);
$me.toggleClass("ui-state-active");
autoedit = $me.hasClass("ui-state-active");
$me.attr("aria-pressed", autoedit ? "true" : "false");
}
});
$("#grid_toppager")
.find(".ui-pg-button")
.each(function (i) {
$(this).attr({
tabindex: String(i),
role: "button"
});
});
//$("#AutoEdit").attr("role", "button");
if (autoedit) {
$("#AutoEdit").click();
}
$grid.jqGrid("navButtonAdd", "#grid_toppager", {
buttonicon: "fa-table",
caption: "Columns",
title: "Choose columns",
onClickButton: function (options, e) {
$(this).jqGrid("columnChooser");
}
});
$("#grid_toppager_left").hide();
$("#grid_toppager_right").hide();
$("#grid_toppager_center").attr("colspan", "2");
$("#grid_toppager_center").css({width: "", "text-align": "left", "white-space": ""});
$("#grid_toppager_center").find(">.navtable").append(
$("#grid_toppager_center").find(">table.ui-pg-table")
);
$("#grid_toppager_center").find(">.navtable").children().each(function() {
$(this).css("float", "left");
});
$grid.bind("jqGridAfterGridComplete", function () {
var p = $(this).jqGrid("getGridParam"), $toppager = $(p.toppager);
$toppager.find(".navtable").css("width", "");
});
});
//]]>
</script>
</head>
<body>
<div id="outerDiv" style="margin:5px;">
<table id="grid"></table>
</div>
</body>
</html>
最佳答案
免费的 jqGrid 4.8 基于 jqGrid 4.7 版本。如果你检查 the lines of code您会看到所描述的行为是使用默认 shrinkToFit: true
选项时的标准行为。因此,如果您使用默认的 shrinkToFit: true
选项,您将在 columnChooser
中有相同的行为。
如果在您的环境中无法使用 shrinkToFit: false
选项,请写信给我。
关于jquery - 如何保持列的网格宽度在列菜单中切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29455752/
我的理解是 width: 100% 让元素的宽度与其父元素的宽度相同,而 width: inherit 只有在明确指定父元素的宽度时才这样做.这种理解是否正确? 如果是这样,在我看来,当 width:
并设置“高度”为全屏的 1/2。 这是我的代码: div{ background:red; } 最佳答案 我会结合使用 css 和 javascript(使
编辑 2: 问题似乎出在规则的“bigTable”元素上。显然,在布局模板上使用时继承了错误的最小宽度。我仍在调查此事。 不过,我将再尝试一次 div。一个大问题是使用固定导航和动态内容,但我已经为此
我的网站需要显示宽表。在它上面是标题,它应该和整个页面一样宽(在这种情况下,和表格一样宽)。但是,它的宽度与视口(viewport)(屏幕尺寸)一样宽,因此显示时看起来还不错,但是一旦用户滚动到侧面,
我有一个小问题。我总是使用 float 来安排我的元素。我正在转向 flexbox,我做了一些例子,一切都很好,但我正在做一个事情进展不顺利的例子。 我有一个包含 1 到 12 种产品的容器,每行 4
例如,它们在自动边距方面会导致完全不同的行为。 看看这个 fiddle :https://jsfiddle.net/L1rk46xy/ .fixed { display:fixed;
我尝试在帖子中将段落的宽度设置为 75%,并将图像的响应宽度设置为 100%。然而,总是在 默认。 Some texts Some texts Some texts Some texts 目前,我只
HTML 元素可以有 width/height 属性,也可以有 CSS width/height 属性: HTML 属性和 CSS 属性有什么区别,它们应该具有相同的效果吗? 最佳答案 有关该主题的
我有一个流动的 table ,现在需要一个固定的 thead。问题是当你固定 thead 时,th-s 不尊重 tbody 的 td-s 的宽度。列的大小都由 BootStrap 处理。我已经阅读了很
我想像这样布置一个区域: ---- ---- |A | |B | | | | | ---- ---- --------- |C | --------- 三个盒子中的每一个都是 .盒子
我遇到了很多问题。 1) 我正在使用 Bootstrap-Select 来获得具有搜索功能的现代选择框,但无论我尝试什么,我似乎都无法获得填充 col-span 的选择。 2) 我已将该行拆分为 2
http://jsfiddle.net/95EtZ/1/ 问题在行动中解决了一半。 现在它是用 javascript 中硬编码的容器宽度设置的。 我需要 js 来获取容器 div 的宽度——使用窗口滚
我想要两个宽度和高度均为 100% 的 div。我知道子 div 不会工作,因为父 div 没有特定的高度,但有没有办法解决这个问题? HTML: CSS: body
我需要使用 jQuery 更改 的高度和宽度 我尝试了以下代码 jQuery('#chart_popup').css('height','600px'); jQuery('#chart_popup')
在自定义 WPF 控件中,我想将控件的宽度设置为高度的函数。例如:Width = Height/3 * x; 实现此目的的最佳方法是什么,以便控件正确且流畅地调整大小(和初始大小)? 最佳答案 您可以
我正在使用igraph在R中绘制图形,执行plot(mygraph, vertex.color = "green")之类的操作。 有没有办法改变顶点边界的颜色和/或宽度? 最佳答案 查看下面的代码;
有没有办法使用jquery设置图像的高度和宽度?以下是我的代码 var img = new Image(); // Create image $(img).load(function(){
这个问题类似于 how-to-find-the-actual-width-of-grid-component-with-scrollbar-in-delphi 但我无法获取 CalcDrawInfo(
这里是 HTML/CSS 新手。 试图将我在 Codeacademy 上学到的知识付诸实践,但我遇到了一个问题,即我设置为 width:100% 的 header 最终离开了页面。我相信这是因为边框,
这里是 HTML/CSS 新手。 试图将我在 Codeacademy 上学到的知识付诸实践,但我遇到了一个问题,即我设置为 width:100% 的 header 最终离开了页面。我相信这是因为边框,
我是一名优秀的程序员,十分优秀!