We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

clearSelection after rowselected

Dear all,

We try to add grid with javascript as follow :

ej.grids.Grid.Inject(ej.grids.Page, ej.grids.Sort, ej.grids.Filter);

                grid = new ej.grids.Grid({

                    dataSource: ListArr,

                    columns: [

                        { field: 'Id', headerText: 'Camera ID', width: 120, type: 'string',visible:false },

                        { field: 'Name', width: 140, headerText: 'Camera Name', type: 'string' }

                    ],

                    toolbar: ['Search'],

                    allowSorting: true,

                    allowPaging: true,

                    pageSettings: { pageSize: 20 },

                    rowSelected: rowSelected

                });


                grid.appendTo('#Grid');


        function rowSelected(args) {


                var selectedIndex = $.map(ListArr, function (item, index) {

                    return item.Id;

                }).indexOf(args.data.Id);


            if (currContainer === "") {

                alert("error");

                grid.clearSelection();

            }

            else

                buildCameraElement(cameraArr[selectedIndex]);

        }


After display the alert message, we fail to clear the selected highlight row. Please advance, thx.

KennethT 

1 Reply

PS Pavithra Subramaniyam Syncfusion Team June 27, 2019 11:36 AM UTC

Hi Kenneth, 
 
Thanks for contacting Syncfusion support. 
 
You can achieve the clear selection inside the rowSelected event as below. Please refer to the below code example and sample link for more information. 
 
[index.js] 
var data = new ej.data.DataManager(window.orderData).executeLocal(new ej.data.Query().take(15)); 
      grid = new ej.grids.Grid({ 
           dataSource: data, 
           columns: [ 
              { field: 'OrderID', headerText: 'Camera ID', width: 120, type: 'string',visible:false }, 
              { field: 'CustomerID', width: 140, headerText: 'Camera Name', type: 'string' } 
                     ], 
            pageSettings: { pageSize: 20 },      
            rowSelected: rowSelected 
             }); 
      grid.appendTo('#Grid'); 
       function rowSelected(args) {        
            if (args.data.OrderID === 10248) { 
                alert("error"); 
                setTimeout((e)=>{ 
                  grid.clearSelection() 
                  }) 
            } 
       } 
 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 


Loader.
Live Chat Icon For mobile
Up arrow icon