jqgrid - toolbar text - is this a good way of doing it?

后端 未结 1 888
独厮守ぢ
独厮守ぢ 2021-01-16 10:48

I have specified userdata in JSON response. Depending on the value of the title property,

  • the caption will change to reflect the val
1条回答
  •  渐次进展
    2021-01-16 11:37

    There are no methods for changing of content top or bottom toolbars added by toolbar option of jqGrid, but you can use setCaption to set grid caption (title). The small modified demo of your code uses the following loadComplete:

    loadComplete: function () {
        var $this = $(this), userdata = $this.jqGrid('getGridParam', 'userData');
        if (userdata && userdata.title) {
            $this.jqGrid('setCaption', userdata.title);
        }
        if (userdata.title === "My Title 1") {
            $this.jqGrid('setCaption', "Viewing the Records.");
            $('#t_' + $.jgrid.jqID(this.id))
                .append('
    Viewing the Records.
    '); } else if (userdata.title === "My Title 2") { $this.jqGrid('setCaption', "Editing the Records."); $('#t_' + $.jgrid.jqID(this.id)) .append('
    Editing the Records.
    '); } }

    The usage of $.jgrid.jqID(this.id) instead of this.id is helpful in the case if the id of the grid (in you case 'myjqgrid') contains some meta-characters.

    0 讨论(0)
提交回复
热议问题