Select record programmaticaly

Hello,

I try to select a record programmatically. In the code I've an ajax method :

     var gridObject = document.getElementById("FlatGrid").ej2_instances[0];
     $.ajax({
        method: "POST",
        url: urlPostCreateUpdateModal,
        cache: false,
        processData: false,
        contentType: false,
        data: formData,
        beforeSend: function () {
            ...
        },
        complete: function () {
           if (typeof $("#FlatGrid").attr("data-update-pendinglist") == "undefined") {
                //Une fois l'ajax terminé on remove le loader et on ré affiche la vue partielle avec l'élément inséré
                $('#loaderModalConnection').remove();
                $("#partial").show();
            }
        }
    }).done(function (result) {
        gridObject.dataSource = JSON.parse(result);
        gridObject.selectionModule.selectRow(selectedRowIndex, true);
    }).fail(function (result) {
        console.log("fail")
    });

But when the grid is rendered, my row is not selected. I used selectionModule.selectRow like here in the doc.
The grid is in the #partial

Regards

1 Reply

HJ Hariharan J V Syncfusion Team August 24, 2018 10:29 AM UTC

Hi Thibault , 
 
Thanks for contacting Syncfusion support. 
 
We suspect you are to trying to select grid rows before grid row elements rendered, so we suggest you to invoke `selectRow` method in the databound event. Also, you can achieve the same requirement(“Select grid rows on initial rendering”) using the `selectedRowIndex` grid property. Please refer the below sample and documentation links. 
 
 
 

Regards, 
Hariharan 


Loader.
Up arrow icon