- Home
- Forum
- ASP.NET MVC - EJ 2
- Two grid on same page with datamanager
Two grid on same page with datamanager
Hi, how can I have two grid on the same page that load data with
dataManager.Url("/Home/UrlDatasourceProducts").Adaptor("UrlAdaptor").InsertUrl("/Home/InsertProducts").UpdateUrl("/Home/UpdateProducts").RemoveUrl("/Home/DeleteProducts");}
and
dataManager.Url("/Home/UrlDatasourceList").Adaptor("UrlAdaptor").InsertUrl("/Home/InsertList").UpdateUrl("/Home/UpdateList").RemoveUrl("/Home/DeleteList");}
Thank you.
SIGN IN To post a reply.
9 Replies
MP
Manivannan Padmanaban
Syncfusion Team
June 10, 2019 08:28 AM UTC
Hi Massimo,
Thanks for contacting Syncfusion Support.
Query: Two grid on same page with dataManager.
From the above query, we are able to understand that you want to render the two grids within the same page with dataManager UrlAdaptor. For your convenience we have created the sample, kindly refer the below link.
If we misunderstood your query, please get back to us with the below details.
- Explain your requirement in detail. Also, confirm whether are you using the Asp.net MVC platform. If not, please share the platform are you using.
Regards,
Manivannan Padmanaban.
MA
Massimo
June 10, 2019 02:10 PM UTC
Hi, I understand with your example where was my fault.
I've a last question regards this two grids with
first grid:
dataManager.Url("/Home/UrlDatasourceProducts").Adaptor("UrlAdaptor").InsertUrl("/Home/InsertProducts").UpdateUrl("/Home/UpdateProducts").RemoveUrl("/Home/DeleteProducts");}
...
col.Field("Id").HeaderText("Id").IsPrimaryKey(true).Visible(true).Width("150").Add();
col.Field("Product").HeaderText("Product").Visible(true).Width("150").Add();
...
second grid:
dataManager.Url("/Home/UrlDatasourceList").Adaptor("UrlAdaptor").InsertUrl("/Home/InsertList").UpdateUrl("/Home/UpdateList").RemoveUrl("/Home/DeleteList");}
...
col.Field("Id").HeaderText("Id").IsPrimaryKey(true).Visible(false).Width("100").Add();
col.Field("IdProduct").HeaderText("IdProduct").Visible(true).Width("100").AllowEditing(false).Add();
col.Field("Product").HeaderText("Product").ForeignKeyField("IdProduct").ForeignKeyValue("Product").Visible(true).Width("150").AllowEditing(false).Add();
How can reach the render of the column Product in the second grid? This Product column is the Product column of the first grid joined by Products.Id = List.IdProduct
Actually the column is render empty.
Thank you.
MP
Manivannan Padmanaban
Syncfusion Team
June 11, 2019 06:10 AM UTC
Hi Massimo,
Thanks for the update.
Query: How can reach the render of the column Product in the second grid? This Product column is the Product column of the first grid joined by Products.Id = List.IdProduct
Actually the column is render empty.
We suspect that the above reported issue(column is render empty) will occur because you have not defined the dataSource for the foreignkey column. Kindly refer the below links,
Help documentation link – https://help.syncfusion.com/aspnetmvc/grid/columns#foreign-key-column
Regards,
Manivannan Padmanaban.
MA
Massimo
June 11, 2019 06:29 AM UTC
Hi Manivannan,
thanks for the fast reply.
You're right. Is missing the dataSource similar to:
.DataSource((IEnumerable<object>)ViewBag.dataSource2)
but, how can reach the correct dataSource when there are remote data like as:
public ActionResult UrlDatasourceProducts(DataManagerRequest dm)
{
ModelEntities db = new ModelEntities();
IEnumerable DataSource = db.Table02_Products.ToList();
DataOperations operation = new DataOperations();
if (dm.Search != null && dm.Search.Count > 0)
{
DataSource = operation.PerformSearching(DataSource, dm.Search); //Search
}
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
DataSource = operation.PerformSorting(DataSource, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
}
int count = DataSource.Cast<Table02_Products>().Count();
if (dm.Skip != 0)
{
DataSource = operation.PerformSkip(DataSource, dm.Skip); //Paging
}
if (dm.Take != 0)
{
DataSource = operation.PerformTake(DataSource, dm.Take);
}
return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource, JsonRequestBehavior.AllowGet);
}
Regards,
MP
Manivannan Padmanaban
Syncfusion Team
June 11, 2019 07:14 AM UTC
Hi Massimo,
Thanks for the update.
Query: but, how can reach the correct dataSource when there are remote data like as:
We can define the remote data for the grid column dataSource as like below,
|
@(Html.EJ().Grid<object>("Editing")
……………………………………………….
………………………………………
.Columns(col => {
………………………………..
col.Field("EmployeeID").HeaderText("Employee ID").ForeignKeyField("EmployeeID").ForeignKeyValue("FirstName")
.DataSource(ds => ds.URL("/Grid/ColumnData").Adaptor(AdaptorType.UrlAdaptor)).AllowEditing(true)
.EditType(EditingType.DropdownEdit)
.FilterType(FilterOption.Excel)
……………………………………………………..
})
)
public ActionResult ColumnData(DataManager value)
{
…………………………………………………..
}
|
Regards,
Manivannan Padmanaban.
MA
Massimo
June 11, 2019 08:15 AM UTC
Hi Manivannan,
is not clear for me the ………………………………………………….. in the ActionResult ColumnData
May I have a EJS little example please?
Regards,
PS
Pavithra Subramaniyam
Syncfusion Team
June 12, 2019 04:23 PM UTC
Hi Massimo,
As per your request we have created a foreignKey column sample in EJ2Grid and you can find that sample from the below link,
Regards,
Pavithra S.
MA
Massimo
June 13, 2019 05:57 AM UTC
Hi Pavithra,
this example solve my problem.
Thank you very much!
PS
Pavithra Subramaniyam
Syncfusion Team
June 13, 2019 10:48 AM UTC
Hi Massimo,
Thanks for your update.
We are glad to hear that your problem has been resolved.
Please get back to us if you need any further assistance on this.
Regards,
Pavithra S.
SIGN IN To post a reply.
- 9 Replies
- 3 Participants
-
MA Massimo
- Jun 7, 2019 07:46 AM UTC
- Jun 13, 2019 10:48 AM UTC