- Home
- Forum
- ASP.NET MVC
- Get all data from Grid
Get all data from Grid
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();
})
.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 )
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; "
SIGN IN To post a reply.
3 Replies
VN
Vignesh Natarajan
Syncfusion Team
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
AL
Alexandre
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?
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?
VN
Vignesh Natarajan
Syncfusion Team
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
AL Alexandre
- Feb 5, 2019 05:36 PM UTC
- Feb 7, 2019 08:49 AM UTC