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. Image for the cookie policy date

Add a column with the Add(string mappingName) method

Hi all,

I have a MVC typed grid, but I don't know the type (it looks like Html.Syncfusion.Grid where T:class).

So I can't use lambda expression to add columns, I"m looking on the Add(string mappingName) method.

For example, if I have a grid of customers which contains a name property, I would like add the column like this:

column => column.Add("Name"). I can't do column=>column.Add(c=>c.Name), because I don't know the type of my datas, and I don't have to know it.

But it doesn't work ! I have empty cells...

Thanks for your help.



1 Reply

ES Eswari S Syncfusion Team December 5, 2011 01:04 PM UTC

Hi SebFrance,

Thank you for using Syncfusion products.

Query #1 : , I"m looking on the Add(string mappingName) method

Your requirement can be achieved by specifying the “MappingName” of the column. And also we need to set the Unbound as false for those columns.

<%=Html.Syncfusion().Grid("OrdersGrid")
. . . . .
. . . .
.Column(col =>
{
//set UnBound as false , otherwise columns will be treated as unbound column and it will empty without any data's

col.Add("OrderID").UnBound(false);
col.Add("CustomerID").UnBound(false);
col.Add("EmployeeID").UnBound(false);
col.Add("ShipCity").UnBound(false);
col.Add("Freight").UnBound(false);
col.Add("ShipCountry").UnBound(false);
})


%>


For your convenience , we have prepared the sample and the same can be downloaded from the following link :

http://www.syncfusion.com/downloads/Support/DirectTrac/87446/Sample-346942925.zip


Note: If you want to run the sample in MVC3, change the configuration manager as Debug_MVC3/Release_MVC3.To briefly know about that steps please kindly refer this document link.

How to Switch between MVC2 to MVC3

Please try this and let us know if you need any further assistance.

Regards,
Eswari.S




Loader.
Live Chat Icon For mobile
Up arrow icon