Hi Frank,
Thanks for your interest in Syncfusion products.
We are glad to let you know Essential Studio ASP.NET MVC Edition Beta-4 has been launched successfully
Please download and use our latest version at
http://www.syncfusion.com/downloadsUpdated Demo’s at
http://samples.syncfusion.com/mvcgriddemo/v7.2.0.39Grid’s DataSource property accepts any kind of IEnumerable data source. It looks like you are trying to set SQL Query as data source.SQL Query cannot be directly set to datasource.
Please refer the following code snippet for setting data source.
Controller:
[C#]
public ActionResult Index()
{
/// HeaderText property is used to specify the Text to be displayed on the column header
MvcGridModel model = new MvcGridModel()
{
DataSource = MyProject.Models.MyDataContext.Orders.Skip(0).Take(20),
SkinName = "Syncfusion-Grid-Office2007Black",
ActionMode = "Server",
CaptionText = "Orders",
HeaderText = { "Order ID", "Customer ID", "Employee ID", "Ship Name", "Ship Address", "Ship City", "Ship Region", "Ship Postal Code", "Ship Country", "Ship Via", "Order Date", "Required Date", "Shipped Date", "Freight" },
PrimaryKeyColumns = { "OrderID" }
};
ViewData["GridModel"] = model;
return View();
}
View:
[ASPX]
// column.Add() is used add columns in the grid at desired order. This is used to filter out visible columns of the grid.
<%Html.Grid
(
"MvcGridServerMode","GridModel" ,
column =>{
column.Add(p => p.OrderID);
column.Add(p => p.CustomerID);
column.Add(p => p.EmployeeID);
column.Add(p => p.ShipName);
column.Add(p => p.ShipAddress);
column.Add(p => p.ShipCity);
column.Add(p => p.ShipRegion);
column.Add(p => p.ShipPostalCode);
column.Add(p => p.ShipCountry);
column.Add(p => p.ShipVia);
column.Add(p => p.OrderDate);
column.Add(p => p.RequiredDate);
column.Add(p => p.ShippedDate);
column.Add(p => p.Freight);
}); %>
We are using SQLCE Data base .
The following code snippet is used in Application controller as connection string
[C#]
public MvcSampleBrowser.Models.Northwind SqlCE
{
get
{
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
string connectionString = @"Data Source=|DataDirectory|\Northwind.sdf";
return new MvcSampleBrowser.Models.Northwind(connectionString);
}
}
/// SqlCE.Orders-> we can access Orders table from Northwind.sdf.
LINQ Support
Please visit our JSON samples, LINQ data source is used in the JSON mode.
Adding Subset of columns in the grid:
Please use the following lambda expression to add subset of columns what are all the columns are added here will be added to the visible columns collection and gets displayed, Where scenarios requires all columns to be displayed then the third parameter of the Grid() is not required. Options for adding HeaderText and Format from the view will be included in the coming Release.
There are two ways to achieving this
1)Adding visible column from view
[ASPX]
<%Html.Grid(
"MvcGridServerMode","GridModel" ,
column =>{
column.Add(p => p.OrderID);
column.Add(p => p.CustomerID);
column.Add(p => p.EmployeeID);
column.Add(p => p.ShipName);
}); %>
2)Adding visible columns from controller
[C#]
MvcGridModel model = new MvcGridModel();
model.TableDescriptor.VisibleColumns.Add("OrderID");
odel.TableDescriptor.VisibleColumns.Add("CustomerID");
model.TableDescriptor.VisibleColumns.Add("EmployeeID");
model.TableDescriptor.VisibleColumns.Add("ShipName");
3) TemplateId not Displayed Issue
We are unable to re-produce this issue. Nested table samples are available at
http://samples.syncfusion.com/mvcgriddemo/v7.2.0.39/gettingstarted/expand
Please refer our sample in the above link .If you are still facing problems please send us a sample illustrating the issue.
Please let us know if this helps you.
Regards,
Muthukumar.L