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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:23:44+00:00 2026-05-28T01:23:44+00:00

I want to use a grid as subgrid in jqGrid because I read that

  • 0

I want to use a grid as subgrid in jqGrid because I read that “simple subgrid” doesn’t allow cell edit.

I’m filling main Grid with dataType function successfully and I’m trying to do the same for subgrid, but subgrid shows without data, and I don’t know why because I debugged and I catch data correctly from web service, but when I go through the data doing a addRowData to the subgrid seems to have no effect.

I’m using a a ASP.Net 2.0 web service and JSON,Here is the client code, any idea :-S? Thanks 🙂

EDIT:

I added a:

function ReceivedClientData(data) {
    var thegrid = $("#" + gridId);
    if ($(thegrid).length == 0) alert('NOT EXISTS');

    thegrid.clearGridData();
    for (var i = 0; i < data.length; i++)
        thegrid.addRowData(i + 1, data[i]);   
}

And I receive a NOT EXISTS for subgrid, I don’t know if is the best way to check if a selector exists but this would mean that I can’t find “the dynamic ” created by jqgrid when I capture the ajax postback? How can I fill the subgrid?

EDIT 2:

I think that I was wrong with subgrid ID, now I’m saving in a variable the grid_id

subGridRowExpanded: function(subgrid_id, row_id) {
            subGridID = subgrid_id;

and using it when callback, but I’m receiving a p.rownumbers is null from jqgrid.js when I try to addRowData. :-S any suggestions?

function ReceivedClientDataForSubGrid(data) {
    var thegrid = $("#" + subGridID);

    if ($(thegrid).length == 0) alert('NOT EXISTS');

    thegrid.clearGridData();
    for (var i = 0; i < data.length; i++)
        thegrid.addRowData(i + 1, data[i]);
}
  • 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-28T01:23:44+00:00Added an answer on May 28, 2026 at 1:23 am

    Moving the “Edit 3” to an answer to mark the question as answered


    I solved it, I was accesing to an incorrect ID, the correct ID is var thegrid = $(“#” + subGridID + “_t”);

    complete client code

    var gridId = "table";
    $(function() {
        $("#"+gridId).jqGrid({
            datatype: function(pdata) { getData(pdata); },
            height: 250,
            colNames: ['Nombre Objetivo', 'Tipo Objetivo', 'Objetivo Tipo 1', 'Objetivo Tipo 2', 'Objetivo Tipo 3', 'Autoevaluacion', 'Resultado Final', 'Actions'],
            colModel: [
                            { name: 'ObjetivoNombre', width: 200, sortable: false },
                            { name: 'TipoObjetivo', width: 200, sortable: false, editable: true, edittype: 'select', editoptions: { value: { 1: '1', 2: '2', 3: '3'}} },
                            { name: 'ObjetivoTipo1', width: 200, sortable: false, hidden: true },
                            { name: 'ObjetivoTipo2', width: 200, sortable: false, hidden: true },
                            { name: 'ObjetivoTipo3', width: 200, sortable: false, hidden: true },
                            { name: 'Autoevaluacion', width: 200, sortable: false, hidden: false, editable: true },
                            { name: 'ResultadoFinal', width: 200, sortable: false, hidden: false, editable: true },
                            { name: 'act', index: 'act', width: 75, sortable: false }
                        ],
            cellEdit: true,
            cellsubmit: 'clientArray',           
            pager: '#pager',
            rowNum: 10,
            rowList: [10, 20, 30],
            sortname: 'Nombre Objetivo',
            sortorder: 'desc',
            viewrecords: true,
            gridComplete: function() {
                var ids = jQuery("#table").jqGrid('getDataIDs');
                var idsLength = ids.length;
                for (var i = 0; i < idsLength; i++) {
                    var cl = ids[i];
                    de = "<input style='height:22px;width:20px;' type='button' value='D' onclick=\"deleteRow('" + cl + "');\" />";
                    jQuery("#table").jqGrid('setRowData', ids[i], { act: de });
                }
            },
            subGrid: true,          
            subGridRowExpanded: function(subgrid_id, row_id) {
                var subgrid_table_id;
                subgrid_table_id = subgrid_id + "_t";
                jQuery("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table>");
                jQuery("#" + subgrid_table_id).jqGrid(
               {
                   datatype: function(pdata) { getDataSubGrid(pdata); },
                   colNames: ['Nombre Objetivo', 'Tipo Objetivo', 'Objetivo Tipo 1', 'Objetivo Tipo 2', 'Objetivo Tipo 3', 'Autoevaluacion', 'Resultado Final'],//, 'Actions'],
                   colModel: [
                            { name: 'ObjetivoNombre', width: 200, sortable: false },
                            { name: 'TipoObjetivo', width: 200, sortable: false, editable: true, edittype: 'select', editoptions: { value: { 1: '1', 2: '2', 3: '3'}} },
                            { name: 'ObjetivoTipo1', width: 200, sortable: false, hidden: true },
                            { name: 'ObjetivoTipo2', width: 200, sortable: false, hidden: true },
                            { name: 'ObjetivoTipo3', width: 200, sortable: false, hidden: true },
                            { name: 'Autoevaluacion', width: 200, sortable: false, hidden: false, editable: true },
                            { name: 'ResultadoFinal', width: 200, sortable: false, hidden: false, editable: true }
                        ],
                   height: 100,
                   rowNum: 20,
                   sortname: 'num',
                   sortorder: "asc"                  
               });
            },
            caption: "jQGrid Ejemplo"
        })       
    });
            //AJAX GET DATA FROM WS
        function getData(pData) {
            gridId = "table";
            $.ajax({
                type: 'POST',
                contentType: "application/json; charset=utf-8",
                url: '<%= ResolveClientUrl("~/WebService.asmx/ObtenerDatosDPO") %>',
                data: '{}',
                dataType: "json",
                success: function(data, textStatus) {
                        ReceivedClientData(JSON.parse(getMain(data)).rows);
                },
                error: function(data, textStatus) {
                    alert('An error has occured retrieving data!');
                }
            });
        }
        function getDataSubGrid(pData) {
            gridId = "table_t";
            $.ajax({
                type: 'POST',
                contentType: "application/json; charset=utf-8",
                url: '<%= ResolveClientUrl("~/WebService.asmx/ObtenerDatosDPOSubGrid") %>',
                data: '{}',
                dataType: "json",
                success: function(data, textStatus) {
                    ReceivedClientData(JSON.parse(getMain(data)).rows);
                },
                error: function(data, textStatus) {
                    alert('An error has occured retrieving data subgrid!');
                }
            });
        }
    
        //COMMON FUNCTIONS
        function ReceivedClientData(data) {
            var thegrid = $("#"+gridId);
    
            thegrid.clearGridData();
            for (var i = 0; i < data.length; i++)
                thegrid.addRowData(i + 1, data[i]);
        }       
        function getMain(dObj) {
            if (dObj.hasOwnProperty('d'))
                return dObj.d;
            else
                return dObj;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to have a very simple grid and i want to use
I want to create a really easy to use 2D Grid. Each cell in
I am using jQuery 1.6.1 and want to use JqGrid (a grid table plugin
I want to iterate through store and make grid columns dynamically. When I use
I have a transaction log file in CSV format that I want use to
I want to use MvcContrib Grid helper, but i stuck on the problem -
I am using EntityDataSource control to display Data in Grid, I want to use
I want to use a GridView to display data that is separated alphabetically by
I don't want use ajax to load data in my grid. Theres a way
I want to use calendar in my Android application in grid view format and

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.