- Home
- Forum
- ASP.NET MVC (Classic)
- Dynamic Model
Dynamic Model
i'm trying to implement the Syncfusion MVC Grid an i have a problem with my dinamical model in the view.
In my product i have a model which returns a List of dynamical objects (i get the date from a thirth party, so i can't chage it and i won't to wrap it). Here the simple example:
public class Foo
{
public List
{
List
dynamic obj;
for (int i = 0; i < 15; i++)
{
obj = new System.Dynamic.ExpandoObject();
obj.aaa = "aaa";
obj.bbb = "bbb";
obj.ccc = "ccc";
obj.ddd = "ddd";
obj.eee = "eee";
list.Add(obj);
}
return list;
}
}
And here is the controller:
public ActionResult Grid()
{
Foo mod = new Foo();
var myMod = mod.getBoo();
GridPropertiesModel
{
DataSource = myMod,
AllowPaging = true,
AllowSorting = true,
Caption = "All Bla's",
AutoFormat = Skins.Midnight,
AllowFiltering = true,
AllowGrouping = true,
Localize = System.Threading.Thread.CurrentThread.CurrentUICulture.Name,
LocalizationPath = "~/App_GlobalResources"
};
ViewData["GridModel"] = model;
return View();
}
So my question is, how looks the view? Any ideas?
I try with:
@{
Html.Syncfusion().Grid
column =>
{
column.Add(p => p.aaa).HeaderText("This is aaa");
column.Add(p => p.aaa).HeaderText("This is aaa");
});
}
Thanks for using Syncfusion Products.
Currently we do not provide 'support to binding dynamic objects'. This has been confirmed as a Feature Request.
We will implement this feature in our forthcoming new version releases or service pack releases.
We usually have an interval of at least three months between releases. The feature implementation
would also greatly depend on the factors such as product design, code compatibility and complexity.
We will get back to you once the feature is implemented.
Please let us know if you have any concerns.
Regards,
Bala Murugan A.S
thank you for your post.
Is there any workarounds, that can i use?
I get the Model on runtime, so i can't create a model on the desing time.
Kind regards,
Petar Raykov
i have another idea but it doesn’t work too. I would like to have a model with only one property e.g. Values from Type String Array. For instance:
namespace MyNamespace.Models
{
public class TestObject
{
public string[] Values { get; set; }
}
}
The idea is to use a for-loop over the property inside the view. For instance:
@(new HtmlString(Html.Grid
{
for(int i = 0; i < p.Values.Count; i++)
{
columns.Add(p => p.Values[i]);
}
}).ToString()
Is there any workaround?
Kind regards,
Petar Raykov
Thanks for the update.
Currently we are analyzing on your requirement with high priority. We will update you on March 29,2012.
Please let us know if you have any concerns.
Regards,
Bala Murugan A.S
Thanks for your patience,
We are tried on your requirement but there is no workaround available on binding object dynamically. We have prepared simple sample of binding objects to grid with a help of ITypedList and same can be downloaded from the below link.
Sample link: http://www.syncfusion.com/downloads/Support/DirectTrac/91680/DynamicModel-352789180.zip
Could you please have a look at the above sample and let us know if this sample meets your requirement of binding object to grid?
Please let us know if you have any concerns.
Regards,
Bala Murugan A.S
unfortunately this isn't my intention.
I'm implementing a client of a server-client system. The data for the grid comes from the server component via WCF.
I get a table structure as Datatable() with header label and strongly typed values:
ID (int) | Name (string)| Property (int) | Date (date)
1 | lorem | 12 | 12.05.2012
2 | ipsum | 10 | 10.05.2012
3 | dolor | 24 | 14.05.2012
The big problem is, that I don't know the structure (heder names and types) on the DESIGN time, it depends on the server settings.
My intension was to use an ExpandoObject with dynamical properties so I can add them on the run time. As far as I understood the Syncfusion MVC Grid doesn’t support this .NET feature.
So my idea is to use an array, hashtable or datatable as a datacontainer.
The disadvantage of your example is, that the properties of Customer class you are using in your example are known on the design time and this is what I don’t know on the design time.
Kind regards,
Petar Raykov
http://mvc.syncfusion.com/sfmvcsamplebrowser/10.1.0.44/Grid_MVC/Samples/4.0/DataBinding/DynamicDataBinding
Thanks for the update.
We suggest you to refer our online help for your query. Please refer the below link to know about the Dynamic DataBinding in grid.
http://help.syncfusion.com/Ug_101/User%20Interface/ASP.NET%20MVC/Grid/documents/dynamicdatabinding.htm
Please let us know if you have any concerns.
Regards,
Bala Murugan A.S
Thank you for your patience.
We have added the DataTable support for Grid [ASP.Net MVC] control. This is included in our Essential Studio Volume 2 release which is expected to be release on the last of April 2012.
Also, we have planned to implement the Dynamic Expando Object support in our next release. We will update you once it is implemented.
Let me know if you have any concerns.
Regards,
Bharath
Hi German,
Thanks for using Syncfusion Products.
Query : Binding “Data table” to Syncfusion grid.
We are sorry for inconvenience caused. We
are unable to reproduce the issue. We have prepared a simple sample,
demonstrating the working of “ Binding data table to Syncfusion grid” and the same can
be downloaded from the following link below.
Could you please try the sample and get back to us whether you are able to reproduce the issue? If not, could you please give more information or by reproducing the issue in the above sample so that we could sort out the issue and provide you with solution. The information provided would be of great help in resolving the issue.
Please let us know if you have any concerns.
Regards,
Rakesh D
DataTable_293bb129.zip
Thanks for using Syncfusion Products.
Query 1: To edit the datatable in the grid.
We have noticed that you have used “ edit.PrimaryKey(key
=> key.Add(p => p.Table.PrimaryKey)); “ in your view page to
specify the Primary Key property for grid. We suggest you to use the below code
snippet for setting primary key.
[view]
.Editing(edit =>{
edit.PrimaryKey(new string[]{"ObjectId"});
})
For your convenience we have your modified your codes
and created a sample for performing editing, deleting, adding operations in
grid using datatable binding. Please try the below sample and let us know if
you have any concerns.
Rakesh
D
DataTable_d81341da.zip
Hi German,
Thanks for using Syncfusion Products.
Query 1: To edit the datatable in the
grid.
We suggest you to use the below code
snippet for setting primary key.
[view]
.Editing(edit =>{
edit.PrimaryKey(new string[]{"ObjectId"});
})
Query 2: To set Column caption or HeaderText.
To set column caption or HeaderText we suggest you to use
HeaderText property of column. Please refer below code snippet for further
details.
.Column(col =>{col.Add("ObjectId").HeaderText("OBJECT ID");})
For your convenience we have your
modified your codes and created a sample for performing editing, deleting,
adding operations in grid using datatable binding. Please try the below sample
and let us know if you have any concerns.
Rakesh D
Datatable binding_7046c219.zip
Hi Pramod,
We considered this “Editing support for dynamic data binding” as a feature request and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Regards,
Kavitha N.
- 17 Replies
- 8 Participants
-
PR Petar Raykov
- Mar 13, 2012 09:20 AM UTC
- Feb 15, 2016 11:47 AM UTC