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 7006003
In Process

The Archive Base Latest Questions

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

This is in continuation of jqgrid – json looping issue with the difference that

  • 0

This is in continuation of jqgrid – json looping issue with the difference that I have moved the colNames and colModel to JSON.

JSON

{
    "colModel": [
        {
            "name": "linkimg",
            "index": "linkimg",
            "width": 60,
            "align": "left",
            "jsonmap": "cells.0.links"
        }
    ],
    "colNames": [
        "linkimg"
    ],
    "mypage": {
        "outerwrapper": {
            "page": "1",
            "total": "1",
            "records": "1",
            "innerwrapper": {
                "rows": [
                    {
                        "id": "1",
                        "read": true,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-A",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    },
                                    {
                                        "name": "link3"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "2",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-B",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "3",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-C",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "4",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-D",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "5",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-E",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "6",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-F",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "7",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-G",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "8",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-H",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "9",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-I",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "10",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-J",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "11",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-K",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "12",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-L",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "13",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-M",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "14",
                        "read": false,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-N",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "15",
                        "read": true,
                        "cells": [
                            {
                                "label": "linkimg",
                                "value": "Link-O",
                                "links": [
                                    {
                                        "name": "link1"
                                    },
                                    {
                                        "name": "link2"
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        }
    }
}

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",              
                    repeatitems: false
                },
                gridview: true,
                pager: "#Pager",
                rowNum: 2,
                rowList: [2, 4, 6, 8],
                viewrecords: true,              
                recordpos: 'left',
                multiboxonly: true,
                multiselect: true,
                sortname: 'id',
                sortorder: "desc",  
                sorttype: "text",   
                sortable: true,
                caption: "<h2>My JQGrid</h2>",
                width: "1406",      
                height: "100%",
                scrolloffset: 0,    
                loadonce: true,     
                cache: true,
                loadComplete: function(data){

                }
            });
        }
    });
    $("#myjqgrid").jqGrid('navGrid','#Pager');

});

Problem

How do I take formatter: out of the colModel? If I keep it in JSON, the jqgrid does not display.

  • 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:25:21+00:00Added an answer on May 27, 2026 at 9:25 pm

    If you don’t need unformatter you can extend the list of predefined formatters with your formatter:

    $.fn.fmatter.myLinkFormatter = function (val, options, rawObject) {
        ....
    };
    

    and then use "formatter": "myLinkFormatter" in the column definition

    {
        "colModel": [
            {
                "name": "linkimg",
                "index": "linkimg",
                "width": 60,
                "align": "left",
                "formatter": "myLinkFormatter",
                "jsonmap": "cells.0.links"
            }
        ],
        "colNames": [
            "linkimg"
        ],
        "mypage": {
            "outerwrapper": {
            ...
        }
    }
    

    See the demo.

    One more remark: you should move $("#myjqgrid").jqGrid('navGrid','#Pager'); inside of success handler like I done in the demo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a continuation question from a previous question I have asked I now
This is a continuation of the question here: JBoss - does app have to
This post is an continuation of this post I have DlUser Class each object
This is a continuation of the question Java rounded Swing JButton . I have
This question is in continuation of this post , I have tried installing Xerces-C
This is sort of a continuation of this question . I have a file
This is almost continuation of a previous question. Problem showing jqgrid with dynamic column
This is a continuation to this question which Oleg has answered. I have 2
This is a continuation of pyparsing, Each, results name . I've been having great
This a continuation of this question. I have an Address class which contains basic

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.