dhtmlxgrid with multiple loadXML statements problem

This is my problem. I have two grids(parent/child relationship). Parent grid contains school classrooms, child contains names of people in that classroom.

Parent grid has room number column and a checkbox column. If a user checks a classroom, then I want to load the child grid with names that are registered in that class.

If the user clicks on another class, then those names are added to the child grid as well.

Here’s the problem. What’s happening is that if the second class selected has less number of names, then they don’t appear in the child’s grid. The only time subsequent classroom selections appear in the child grid is if the total number of new names is greater then what’s in the child grid.

Also, all child grid records have unique rowId.

Any help is greatly appreciated.



you do not say where you are getting your data from.
if you are using mysql then i would suggest that you refresh the grid with all the students for the classes selected rather than adding the second set of students to the first grid and so on

when a class if checked in the first grid you can built a search query of all the checked classes

Two issues with reloading data; one, that would imply a lot of redundant database hits and two, any activity done to the child grid would always be wiped out.

The database should not be an issue. I use this in both MySql and MSSQL.

loadXML should work.

Dont know if you found your answer or not, but I just ran into the same issue with loading from json data.
What I ended up doing is keeping a cache of the json on the client and each time the request to the server to get additional data, i just added it to the cache and reloaded the grid using the updated cache of json data.

Since my db doesnt have true record number, I have to send it in so that I dont end up with duplicated record numbers in the grid. Not sure if I really needed to do this or not.

example code:
var _selectedResultsCache;
var _lastRecordNumberUsedForSelectedGrid = 0;

 var addSelectionToResults = function (selectedGeoIds, geotypeToAdd)
        var searchData = {
            'LastRecordNumber': _lastRecordNumberUsedForSelectedGrid,
            'OwnerGeoIds': selectedGeoIds,
            'GeoType': geotypeToAdd

        var jsonData = JSON.stringify(searchData);

            url: '<%= Urls.UrlFor<SelectedGeographyInfoInputModel>() %>',
            type: 'POST',
            dataType: 'json',
            contentType: 'application/json',
            data: jsonData,
            success: function (data)
                _lastRecordNumberUsedForSelectedGrid = _lastRecordNumberUsedForSelectedGrid + data.rows.length;

                if (_selectedResultsCache)
                    var rows = _selectedResultsCache.rows.concat(data.rows);
                    _selectedResultsCache.rows = rows;
                } else
                    _selectedResultsCache = data;


                selectedResultsGrid.parse(_selectedResultsCache, "json");