update data of selected rows of ejs-grid

Hi Narsimsetty, 

Greetings from syncfusion support 

We have analyzed your query and we could see that you like to pass the Grid selected records to the server side. Based on your requirement we have prepared a sample and achieved your requirement. Please refer the below code example and sample for more information. 

Fetchdata.component.ts 
 
export class FetchDataComponent { 
    public data: any; 
    public toolbarOptions: ToolbarItems[]; 
    @ViewChild('grid') 
    public grid: GridComponent; 
 
    UpdateSelectedRows() { //button Click event 
       var grid = (document.getElementsByClassName('e-grid')[0] as any).ej2_instances[0]; 
        var selectedRecords = grid.getSelectedRecords(); //get the selected records 
        var rows = JSON.stringify(selectedRecords); 
        var ajaxObj = new Ajax(); 
        ajaxObj.type = 'POST'; 
        (ajaxObj as any).contentType = 'application/json'; 
        ajaxObj.url = '/Home/SelectRecord'; 
        ajaxObj.data = rows; 
        ajaxObj.send().then(function (value) { 
           //you can use the below way to convert the date 
            var parsed = (DataUtil as any).parse.parseJson(value); 
            console.log(parsed); 
        }); 
 
    } 
     
 
ngOnInit(): void { 
       this.data = new DataManager({ 
            url: "/Home/UrlDatasource", 
            adaptor: new UrlAdaptor() 
        }); 
        this.toolbarOptions = ['PdfExport']; 
    } 
     
} 

HomeController.cs 
 
public class SelectedModel 
        { 
            public List<Gridcolumns> rowData { get; set; } 
        } 
 
        public class Gridcolumns 
        { 
            public int OrderID { get; set; } 
            public string CustomerID { get; set; } 
            public int EmployeeID { get; set; } 
            public DateTime OrderDate { get; set; } 
            public double Frieght { get; set; } 
            public string ShipCountry { get; set; } 
            public string ShipCity { get; set; } 
 
 
        } 
        public ActionResult SelectRecord([FromBody]List<Gridcolumns> row) 
        { 
           //here you can get the selected records and update your db from here  
        } 


Screenshot: 

 

Regards,
Rajapandi R 


1 Reply

NC Narsimsetty Chalamaiah February 9, 2021 12:05 PM UTC

Hi Team ,

i am using ejs-grid in my application .

I need to select multiple rows and de select rows  in ejs-grid , then selected rows data need to update in db.

when we click update button i need to be  selected rows  will send to database.

-- update button should be use out side of ejs-grid.





Attachment: update_of_selected_rows_e76fe40f.zip

Loader.
Up arrow icon