【发布时间】:2011-05-17 06:56:27
【问题描述】:
我的一些 jqGrid 在导航栏上有一个奇怪的行为。
在其中一些上,我使用默认的“搜索”和“刷新”按钮,而在这些按钮上,导航区域向左浮动,出现在这些按钮旁边(不应该居中)。
最大的问题发生在我向搜索按钮“搜索”添加文本时。这使得按钮边距被错误地计算,使得霍伯效果边框比实际按钮宽度短。
但就像我说的那样,这只发生在某些情况下,我无法弄清楚正常工作和不正常工作之间的区别。这不是浏览器问题,因为它在所有浏览器中都会发生。
这是一个屏幕截图(注意带有焦点的搜索按钮和导航控件的位置!):
以前有人遇到过这个问题吗?
这是我的配置 os 有这个问题的网格:
$('#ProductBrandListGrid').jqGrid({
url: '<%= ResolveUrl("~/Controls/ProductsControls/Controllers/ProductBrandController.ashx?method=GridDataList") %>',
datatype: 'json',
mtype: 'GET',
colNames: ['Name', 'Description', 'Actions'],
colModel: [
{ name: 'Name', index: 'Name', width: 100, align: 'left', resizable: true, sortable: true, searchoptions: { sopt: ['cn']} },
{ name: 'Description', index: 'Description', align: 'left', resizable: true, sortable: true, searchoptions: { sopt: ['cn']} },
{ name: 'act', index: 'act', width: 25, sortable: false, search: false },
],
pager: $('#ProductBrandListGridPager'),
rowNum: 15,
rowList: [10, 15, 20, 30, 50, 100],
sortname: 'Name',
sortorder: 'asc',
viewrecords: true,
imgpath: '',
caption: '',
width: 200,
height: 400,
gridComplete: function () {
var ids = jQuery("#ProductBrandListGrid").jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
ce2 = "<input type='button' value='details' onclick='ProductBrandItemOpen(\"" + cl + "\")' />";
$("#ProductBrandListGrid").setRowData(ids[i], { act: ce2 });
}
}
});
/* Add this line to show search boxes on the header */
$('#ProductBrandListGrid').jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false });
/* Add this line to allow advanced search using the toolbar button */
$("#ProductBrandListGrid").jqGrid('navGrid', "#ProductBrandListGridPager", { search: true, edit: false, add: false, del: false, searchtext:"Search" });
谢谢, 亚历克斯
【问题讨论】:
-
按钮的宽度可能是固定的。右键单击它并“检查元素”,看看css是否是固定宽度
-
您提到的所有内容都是 css [presentation] 问题,与您的 jqGrid 关系不大
-
哦,你为什么使用
<input ... onclick="..."... />?属性?这是不好的做法,你正在击败 jquerys 任务 lool :) -
@Ariel:我没有为按钮指定任何宽度,除了 jqGrid 和 JQueryUI Smoothness 之外,我没有在该页面上定义任何其他 CSS。 @Val(1):是的,但我没有在上面设置任何样式,即使您忘记了按钮问题,为什么导航控件会向左浮动? @Val(2):我的错……我保证我会把它改成代表:)
-
@AlexCode:从您发布的图片中可以看出,网格的宽度超过了 200px。所以你在某个地方设置了网格宽度。如果您将
width参数的较大值用作您当前使用的 200,您的问题将不会完全解决,但会减少。
标签: javascript jquery jquery-plugins jqgrid