开发者

Apply a label to the rowlist dropdown in jqgrid

jqgrid's rowlist option is an array of integers t开发者_StackOverflow社区hat it uses to construct a dropdown; the user makes a selection from the dropdown to specify how many rows to see on the page. But there's no label next to the dropdown to tell the user what it's for. Has anyone come up with a tidy solution to putting an explanatory label of text next to this dropdown?


Also the guard logic as mentioned above can be implemented as below:

//declare a class level boolean variable as below and then 
//the following logic in the above code
var isPagesizelabelPopulated = false;

if (!isPagesizelabelPopulated)
    {
      $('.ui-pg-selbox').closest("td").before("<td dir='ltr'>Page size</td>");
      isPagesizelabelPopulated=true;
    }


jQuery("#<pager> .ui-pg-selbox").closest("td").before("<td dir='ltr'>No. Of Rows </td>");

Where <pager> is the id of the grid's pager.


Inside the load complete method writing the below code worked for me which is in line with the above approach.

loadComplete: function () {
// some other code here
$('.ui-pg-selbox').closest("td").before("<td dir='ltr'>Page size</td>");
}

where ui-pg-selbox refers to to the rowlist drop down in the grid.


As suggested above you can select the table or div which contains the select input with class ui-pg-selbox and then set the label. You can do it this in the jQuery(window).load() event but not in the jQuery(document).ready(); event bcz those elements may not be available in the ready() state.


solution for : "The problem with this method is that every time they perform some kind of action on the grid, it adds another 'Page size'"

Add a class to the Page size, like Page size

Add an If/Else case in the loadComplete with following statement : if ($(".rowListLabel")[0]) { do the label creation } else { do nothing }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜