Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
id is undefined in onSelectRow
27/10/2011
18:07
Avatar
scawa1952
Villa Rica, Georgia
Member
Members
Forum Posts: 11
Member Since:
26/08/2010
sp_UserOfflineSmall Offline

I am using jqGrid-4.1.2.min.js and seem to be having a problem with the onSelectRow event.

When I click a loaded row, it returns an "undefined" id.   The code in my function then returns the row values in the first row.

Below is my code which is similar to code I have used successfully in the past.   Does anyone know if there is a problem/bug or can a second set of eyes see a problem in my code?

Thank you for your help.

Stephen McConnell

/*
 * Creates the grid in the Schedule Tab and makes the Web Service call to populate the Grid.
 */
function createScheduleTab() {
    jQuery("#raceGrid").jqGrid({
        datatype: "local",
        colNames:['Id', 'Race No','Race Id', 'Series', 'Date','Race Name','Track Name'],
        colModel:[
            {name:'gridid',index:'gridid', width: 50},
            {name:'racenumber',index:'racenumber', width:50},
            {name:'raceid',index:'raceid', width:50, align: "center"},
            {name:'series',index:'series', width:50, align:"center"},
            {name:'racedate',index:'racedate', width:80, align:"left"},
            {name:'racename',index:'racename', width:200,align:"left"},
            {name:'trackname',index:'trackname', width:200, sortable:false}
        ],
        multiselect: false,
        rowNum:10,
        rowList:[10,20,30],
        pager: '#racePgr',
        sortname: 'gridid',
        sortorder: "desc",
        viewrecords: true,
        caption: "Scheduled Races",
        onSelectRow: function(id, status) {
        
            var gridRow = $(this).getRowData(id);
            var raceId = gridRow["raceid"];
            alert("Selected Row: " + id + " raceId: " + raceId);
            
            
        }    
    });
    jQuery("#raceGrid").jqGrid('navGrid','#racePgr',{add:false,edit:false,del:false});
    
    loadRaceGrid();
}

/*
 * Makes the Web service call to a Java class to load the Scheduled Races JSON object.
 */
function loadRaceGrid() {
    $.getJSON("/services/raceevents/getScheduledRaces",
        function(data){
            if(typeof(data.error) == "undefined") {
                   populateRaceGrid(data);
            } else {
                alert(data.error);
               }
    });
}

/*
 * Takes the Returned JSON data and populates the Scheduled Race Grid.
 */
function populateRaceGrid(data) {
    var myData = new Array();
    var grid = $("#raceGrid");
    
    for(var i = 0; i < data.races.length; i++) {
        myData[i] = [
            {
                gridid: data.races[i].id,
                racenumber: data.races[i].racenumber,
                raceid: data.races[i].raceid,
                series: data.races[i].series,
                racedate: data.races[i].racedate,
                racename: data.races[i].racename,
                trackname: data.races[i].trackname
            }
        
        ];
    }
    
    grid.jqGrid('clearGridData');
    for(var i=0;i< myData.length;i++) {
        grid.jqGrid('addRowData',i+1,myData[i]);
    }
}

Stephen McConnellnnn"Boredom is a personal defect."n -- Lamar Stephens

27/10/2011
21:09
Avatar
scawa1952
Villa Rica, Georgia
Member
Members
Forum Posts: 11
Member Since:
26/08/2010
sp_UserOfflineSmall Offline

Ok.... Solved the problem in my code.

In my function "populateRaceData", I needed to add the following line of code after the for loop that adds the data to the grid to tigger a reload.   I don't know why, but that fixed it.  Confused

    grid.setGridParam({ rowNum: 10 }).trigger("reloadGrid");

Stephen McConnellnnn"Boredom is a personal defect."n -- Lamar Stephens

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
49 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information