Shudmeyer
Shudmeyer

Reputation: 352

jqgrid subgrid row_id with spaces not working php jquery

I know subgrid of jqgrid will not work when an id has an space on it right or am wrong? If right is there a possible way to add id with spaces like "New Zealand". My id's our countries. Please see my code.

subGridRowExpanded: function(subgrid_id, row_id) {
        var subgrid_table_id, pager_id; subgrid_table_id = subgrid_id+"_t";
        pager_id = "p_"+subgrid_table_id;
        $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
        $("#"+subgrid_table_id).jqGrid({
            datatype: "json",
            width: 500,
            url: "link.php?type="+row_id,

Is this possible that row_id or subgrid can accept texts with spaces? I dont have any unique keys for this just text. Please help.

Upvotes: 0

Views: 268

Answers (2)

Rajesh Kumar
Rajesh Kumar

Reputation: 79

the solution is simple, you just need to add a hidden column that can be row number and make that as a key column.

colModel: [
     { name: "KeyColumn", formatter: KeyColumn, key: true, hidden: true, } ],

and the following function :

//KeyColumn
function KeyColumn(cellvalue, options, rowObject) {
    return options.rowId;

}

Upvotes: 2

ahren
ahren

Reputation: 16961

ID's cannot contain spaces.

Just replace them:

myID = "New Zealand";

myID = myID.replace(" ", "_");

console.log(myID); // New_Zealand

Upvotes: 0

Related Questions