serialize modified grid rows into json

In a grid, I would like to serialize modified rows (or any rows I choose) into your json format. Do you have a javascript example on how to accomplish this?



Thanks!

Unfortunately, grid can be serialized only into xml and csv srting. Also there are some internal methods which allow to serialize selected rows to xml or csv. If you need, we can provide you this information.

I was able to write some javascript to create the json I needed:

function getAllRowsAsJson() {
   
    var json = “{rows:[”;
   
    for (var rowIndex=0; rowIndex<mygrid.getRowsNum(); rowIndex++) {
        json = json + “{id:” + mygrid.getRowId(rowIndex) + “,data:[”;
        for(var cellIndex = 0; cellIndex < mygrid.getColumnsNum(); cellIndex++){
            if (cellIndex==0){
                json = json + ‘"’ + mygrid.cells2(rowIndex,cellIndex).getValue() + ‘"’;
            }
            else {
                json = json + “,” + ‘"’ + mygrid.cells2(rowIndex,cellIndex).getValue() + ‘"’;
            }
        }
        if (rowIndex<(mygrid.getRowsNum()-1)){
            json = json + “]},”;
        }
        else {
            json = json + “]}”;
        }      
    }
    json = json + “]}”;
   
    return json.toString();

}

This approach is absolutely correct and can be used in order to serialize to json string. Thank you for provided  method.