jqgrid filterToolbar搜索输入对齐中心

时间:2012-12-12 08:14:04

标签: jqgrid

我在网格中添加了一个filterToolbar搜索框,并改变了它的高度样式 在this问题中。

我想将此输入置于中心位置, (我尝试了text-align:center,但它没有用)。 如何将输入框置于列标题中心?

更新 这是我的colModel代码:

{width:10,name:'Code1',index:'Code1', jsonmap:'Code1',searchoptions:{dataInit: function(elem){$(elem).css('font','15px'); $(elem).height(18);}}},
{width:40,name:'DescriptionHe1',index:'DescriptionHe1', jsonmap:'DescriptionHe1',searchoptions:{dataInit: function(elem){$(elem).css('font','15px');$(elem).height(18);}}, hidden:(language == "he")?false:true},
{width:40,name:'DescriptionEn1',index:'DescriptionEn1', jsonmap:'DescriptionEn1',searchoptions:{dataInit: function(elem){$(elem).css('font','15px');$(elem).height(18);}}, hidden:(language == "en")?false:true},                                                    
{width:10,name:'Code2',index:'Code2', jsonmap:'Code2',searchoptions:{dataInit: function(elem){$(elem).css('font','15px'); $(elem).height(18);}}},
{width:40,name:'DescriptionHe2',index:'DescriptionHe2', jsonmap:'DescriptionHe2',searchoptions:{dataInit: function(elem){$(elem).css('font','15px');$(elem).height(18);}}, hidden:(language == "he")?false:true},
{width:40,name:'DescriptionEn2',index:'DescriptionEn2', jsonmap:'DescriptionEn2',searchoptions:{dataInit: function(elem){$(elem).css('font','15px');$(elem).height(18);}}, hidden:(language == "en")?false:true}                                                    

感谢提前。

1 个答案:

答案 0 :(得分:2)

我认为您使用的其他CSS会更改jqGrid的默认行为。 jqGrid center 默认情况下搜索工具栏中的所有输入字段

要更改搜索栏中元素的样式,您可以使用searchoptionsattr

The demo显示以下内容:

enter image description here

演示使用

cmTemplate: {
    searchoptions: {
        attr: {
            style: "width:auto;padding:0;max-width:100%"
        }
    }
}

为搜索栏的所有元素设置通用样式。另外,我为不同的列设置了maxlengthsize属性。例如

searchoptions: { attr: { maxlength: 6, size: 6 }}

Another demo显示了如何为搜索工具栏的不同元素设置不同的对齐方式:

enter image description here

在我用于左对齐字段的演示中,属性

searchoptions: {
    attr: {
        maxlength: 6,
        size: 6,
        style: "width:auto;padding:0;max-width:100%;float:left"
    }
}

searchoptions: {
    attr: {
        maxlength: 6,
        size: 6,
        style: "width:auto;padding:0;max-width:100%;float:right"
    }
}

用于右对齐字段。

设置我在height内使用searchoptions.attr.style的输入字段的高度:

style: "width:auto;padding:0;max-width:100%;height:5em;float:left"

P.S。我另外使用了CSS

.ui-jqgrid .ui-jqgrid-htable .ui-search-toolbar th {
    height: auto; padding-bottom: 1px
}

提高搜索工具栏的可见度。