Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:41:42+00:00 2026-05-27T21:41:42+00:00

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

  • 0

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

  • the caption will change to reflect the value of the title property
  • the text in the toolbar (between the grid caption and data table headers) will change

HTML

<table id="myjqgrid"></table>
<div id="Pager"></div>  

JSON

{
    "colModel": [
        {
            "name": "ID",
            "label": "ID",
            "width": 60,
            "align": "left",
            "jsonmap": "cells.0.value",
            "sortable": true      
        },
        {
            "name": "FirstName",
            "label": "FirstName",
            "width": 100,
            "align": "left",
            "jsonmap": "cells.1.value",
            "sortable": false       
        },
        {
            "name": "LastName",
            "label": "LastName",
            "width": 100,
            "align": "left",
            "jsonmap": "cells.2.value",
            "sortable": false       
        }
    ],
    "colNames": [
        "ID",
        "FirstName",
        "LastName"
    ],
    "mypage": {
        "outerwrapper": {
            "page":"1",
            "total":"1",
            "records":"20",
            "innerwrapper": {
                "rows":[
                    {
                        "id":"1",
                        "cells":
                        [               
                            {
                                "value":"12345",
                                "label": "ID"                       
                            },
                            {
                                "value":"David",
                                "label": "FirstName"    
                            },
                            {                           
                                "value":"Smith",
                                "label": "LastName"                         
                            }                                                                                       
                        ]       
                    },
                    {
                        "id":"2",
                        "cells":
                        [               
                           {
                                "value":"37546",
                                "label": "ID"                       
                            },
                            {
                                "value":"Willy",
                                "label": "FirstName"    
                            },
                            {                           
                                "value":"Peacock",
                                "label": "LastName"                         
                            }                                                                                       
                        ]       
                    },
                    {
                        "id":"3",
                        "cells":
                        [               
                            {
                                "value":"62345",
                                "label": "ID"                       
                            },
                            {
                                "value":"Kim",
                                "label": "FirstName"    
                            },
                            {                           
                                "value":"Holmes",
                                "label": "LastName"                         
                            }                                                                                       
                        ]       
                    },
                    {
                        "id":"4",
                        "cells":
                        [      
                            {
                                "value":"186034",
                                "label": "ID"                       
                            },
                            {
                                "value":"Andy",
                                "label": "FirstName"    
                            },
                            {                           
                                "value":"Wills",
                                "label": "LastName"                         
                            }                                                                                       
                        ]       
                    },
                    {
                        "id":"5",
                        "cells":
                        [              
                            {
                                "value":"67345",
                                "label": "ID"                       
                            },
                            {
                                "value":"Paul",
                                "label": "FirstName"    
                            },
                            {                           
                                "value":"Lawrence",
                                "label": "LastName"                         
                            }                                                                                       
                        ]       
                    },
                    {
                        "id":"6",
                        "cells":
                        [              
                            {
                                "value":"12906",
                                "label": "ID"                       
                            },
                            {
                                "value":"Andy",
                                "label": "FirstName"    
                            },
                            {                           
                                "value":"Charlery",
                                "label": "LastName"                         
                            }                                                                                       
                        ]       
                    },
                    {
                        "id":"7",
                        "cells":
                        [              
                            {
                                "value":"564565",
                                "label": "ID"                       
                            },
                            {
                                "value":"Bets",
                                "label": "FirstName"    
                            },
                            {                           
                                "value":"Josilyn",
                                "label": "LastName"                         
                            }                                                                                       
                        ]       
                    }
                ],
                "userdata": {
                    "title": "My Title 1"     // this can be 'My Title 1' or 'My Title 2'                   
                }
            }
        }
    }
}

JQGrid Definition

$(document).ready(function () { 
    $.ajax({
        type: "GET",
        url: "myjqgrid.json",
        data: "",
        dataType: "json",
        success: function(response){
            var columnData = response.mypage.outerwrapper,
                columnNames = response.colNames,
                columnModel = response.colModel;

            $("#myjqgrid").jqGrid({
                datatype: 'jsonstring',
                datastr: columnData,                
                colNames: columnNames,
                colModel: columnModel,
                jsonReader: {
                    root: "innerwrapper.rows", 
                    userdata: "innerwrapper.userdata",             
                    repeatitems: false
                },
                gridview: true,
                pager: "#Pager",
                rowNum: 21,
                rowList: [21],
                viewrecords: true,              
                recordpos: 'left',
                multiboxonly: true,
                multiselect: true,
                width: "1406",      
                height: "auto",
                loadonce: true, 
                toolbar: [true,"top"],  
                loadComplete: function(){
                    var userdata = $("#myjqgrid").jqGrid('getGridParam', 'userData');
                    if (userdata) {
                        if (userdata.title) {
                            $("#myjqgrid").jqGrid('setCaption', userdata.title);
                        }
                    }
                    if (userdata.title === "My Title 1") {
                        $("div#t_myjqgrid").append("Viewing the Records.");
                    } else if (userdata.title === "My Title 2") {
                        $("div#t_myjqgrid").append("Editing the Records.");
                    }
                }
            });
            $("#myjqgrid").jqGrid('navGrid','#Pager', {add:false, edit:false, del:false, position: 'right'});
        }
    });
});

My Question is

Is this the right way of changing the content of div#t_myjqgrid? Or does jqgrid offer a property/method/event that I can use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:41:43+00:00Added an answer on May 27, 2026 at 9:41 pm

    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('<div style="margin: 0.3em">Viewing the Records.</div>');
        } else if (userdata.title === "My Title 2") {
            $this.jqGrid('setCaption', "Editing the Records.");
            $('#t_' + $.jgrid.jqID(this.id))
                .append('<div style="margin: 0.3em">Editing the Records.</div>');
        }
    }
    

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic model in which i have specified some of the fields
I have follwowing peace of code in which I have specified the leaky line
previously i had custom tableviewcell and was loading from Nib.in that i have specified
How come this pop-up gets a size other than what I have specified, when
I use WiX3 to generate MSI installation package. I have specified comression flag on
My understanding is floated elements must have their widths specified, or else unpredictable rendering
I have the following column specified in a database: decimal(5,2) How does one interpret
I have foreach function which calls specified function on every element which it contains.
I have a form where I've specified onSubmit=validate() , but I want to ignore
I have a module that sends an email to a specified email address but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.