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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get all data from Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

142472 Feb 5,2019 05:36 PM UTC Feb 7,2019 08:49 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Alexandre
Asked On February 5, 2019 05:36 PM UTC

Hi!
For example, if I have this grid:

@(Html.EJ().Grid<object>("FlatGrid")
                           .Datasource(Model)
                           .ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>
                           {
                               items.AddTool(ToolBarItems.ExcelExport);
                               items.AddTool(ToolBarItems.WordExport);
                               items.AddTool(ToolBarItems.PdfExport);
                           }))
                           .AllowPaging()
                           .AllowFiltering()
                           .FilterSettings(d => d.FilterType(FilterType.FilterBar))
                           .IsResponsive(true)
                           .EnableResponsiveRow(true)
                           .AllowSelection(false)
                           .Columns(col =>
                           {
                               col.Field("UsuarioID").IsPrimaryKey(true).Add();
                               col.Field("Nome").HeaderText("Nome da Rota").Add();
                               col.Field("PrecoMercado").HeaderText("Descricao").Add();
                               col.Field("Tipo").HeaderText("Tipo da rota").Add();
                               col.Field("VigenciaInicio").Format("{0:dd/MM/yyyy}").HeaderText("Data Inicio").Add();
                               col.Field("VigenciaTermino").Format("{0:dd/MM/yyyy}").HeaderText("Data Termino").Add();
                               col.HeaderText("Opções").Commands(commands =>
                               {
                                   commands.Type(UnboundType.Edit).ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()
                                   {
                                       ContentType = ContentType.ImageOnly,
                                       PrefixIcon = "e-icon e-edit",
                                       Click = "onEditClick"
                                   }).Add();

                                   commands.Type(UnboundType.Delete).ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()
                                   {
                                       ContentType = ContentType.ImageOnly,
                                       PrefixIcon = "e-icon e-delete",
                                       Click = "onDeleteClick"
                                   }).Add();
                               }).Add();
                           })

How I can get the columns "UsuarioID" and "PrecoMercado" in Json formatt ?
I know how to get only the primary key, on selected rows, but, now I need to get the data of all rows in the grid, ( I imagine the mechanics are exactly the same )
To get the selected rows, I use this command: "gridObj.checkSelectedRowsIndexes; "


Vignesh Natarajan [Syncfusion]
Replied On February 6, 2019 05:56 AM UTC

Hi Alexandre, 
 
Thanks for using Syncfusion products. 
 
Query: “How I can get the columns "UsuarioID" and "PrecoMercado" in Json formatt ?” 
 
From your query we understand that you need to get the values of selected column while using local data(model) binding. We suggest you to achieve your requirement using Select query of ejDatamanager.  

Refer the below code example
 
 
var obj = $("#FlatGrid").data("ejGrid"); // take the Grid instance 
 
ej.DataManager(obj.model.dataSource).executeLocal(ej.Query().select("OrderID","EmployeeID"));  
 
Refer the below screenshot for the output 
 
 
 
Refer our help documentation for your reference 
 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Alexandre
Replied On February 6, 2019 10:25 PM UTC

Hi Vignesh!
Thanks for the awnser!!

I have not yet tested, I will test soon, but, I will advance my doubt, does this command, used to get the data from grid, preserve the filter applied on the grid?
I mean, when I run the command, "ej.DataManager(obj.model.dataSource).executeLocal(ej.Query().select("OrderID","EmployeeID"));", will the return equal the filtered data?

Vignesh Natarajan [Syncfusion]
Replied On February 7, 2019 08:49 AM UTC

Hi Alexandre, 
 
Query: “I mean, when I run the command, "ej.DataManager(obj.model.dataSource).executeLocal(ej.Query().select("OrderID","EmployeeID"));", will the return equal the filtered data? 
 
From your query, we understand that you need to get the values of certain column from the filtered records. We suggest you to achieve you requirement using getFilteredRecords() method of ejGrid. refer the below code example 
 
var Obj = $("Grid").ejGrid("instance"); // take the Grid instance 
       var filteredRecords = Obj.getFilteredRecords(); // find the filtered data (only for loca data) 
       var value = ej.DataManager(filteredRecords).executeLocal(ej.Query().select("OrderID", "EmployeeID")); // select query to get certain column values. 
 
  
Refer our help documentation for your reference 
 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;