2012-12-12 21 views
1

我加了一個filterToolbar搜索框來我網,改變它的高度風格就像this問題 。的jqGrid filterToolbar搜索輸入居中對齊

我想定位這個輸入在中心, (我試過text-align:center,但它沒有工作)。 如何將輸入框居中在列標題內?

UPDATE: 這是我的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}              

感謝的在進展。

回答

2

我想,您使用的jqGrid變化的默認行爲的其他CSS。 的jqGrid 中心每默認搜索工具欄所有輸入字段。

要更改搜索欄中元素的樣式,您可以使用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" 
    } 
} 

爲右對齊的字段。

要設置我用heightsearchoptions.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 
} 

,以改善搜索工具欄的一個小的知名度。

+0

感謝的了詳細的解答!我嘗試將代碼更改爲你所做的,但它不能很好地工作,我仍然無法看到中心的輸入。我希望搜索輸入與高度一致,並且100%寬度,兩側有一點空間。這可能嗎? (我用我的代碼更新了這個問題)。謝謝! – user590586