This is a migrated thread and some comments may be shown as answers.

RadGrid

2 Answers 9 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 24 Aug 2014, 02:57 AM
Hi Everyone,

I was wondering if someone can provide me with some help or guidance.  I have a RadGrid that is being fill manually(code behind) using entity framework. One of the column contain a foreign key ID(DataField="CostCenterType_ID") which will make no sense to a user.  How can I get it to display primary table description column?  Below is the columns for my grid and code behind to fill it. Thank you in advance....

01.<Columns>
02.        <telerik:GridEditCommandColumn ButtonType="ImageButton" />
03.        <telerik:GridBoundColumn DataField="ID" HeaderText="ID" ReadOnly="true"
04.                    ForceExtractValue="Always" ConvertEmptyStringToNull="true" DataType="System.Int32" />
05.                <telerik:GridBoundColumn DataField="CostCenterNumber" HeaderText="Cost Center No" Visible="true" DataType="System.Int32" />
06.                <telerik:GridBoundColumn DataField="CostCenterName" HeaderText="Cost Center Name" />
07.                <telerik:GridBoundColumn DataField="CostCenterType_ID" HeaderText="Cost Type"/>
08.                <telerik:GridBoundColumn DataField="UpdateBy" HeaderText="Last Update by" ReadOnly="True" Visible="True" AllowFiltering="False" />
09.                <telerik:GridBoundColumn DataField="UpdateDateTime" HeaderText="UpdateDateTime" Visible="true" DataType="System.DateTime" ReadOnly="True" AllowFiltering="False" />
10.                 <telerik:GridBoundColumn DataField="RowVersion" HeaderText="Row Version" DataType="System.Byte" Visible="false" ReadOnly="true"></telerik:GridBoundColumn>
11.                <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
12.                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
13.         </Columns>

1.//Supply RadGrid with data from Entity Framework
2.       protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
3.       {
4.           RadGrid1.DataSource = DbContext.CostCenters;
5.       }

2 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 27 Aug 2014, 11:12 AM
Hi Anthony,

Could you please let me know whether you have the description already stored in your database? If that is correct then you could simply use another column which will show the description and hide the one which contains the ID. Otherwise could you please elaborate a little bit more on the scenario which you are trying to achieve?

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Anthony
Top achievements
Rank 1
answered on 27 Aug 2014, 04:21 PM
Hi Kostadmin,

I forget to post back the answer.  After a good night of rest, I figure out what to do which is pretty simile. I just had to modify my Entity query to include the Discription field and hide the ID like you recommended.  Thank you.
//RadGrid1.DataSource = DbContext.CostCenters;
            var query = (from c in DbContext.CostCenters
                         select new { c.ID, c.CostCenterNumber, c.CostCenterName, c.CostCenterTypeID, c.CostCenterType.NameType, c.UpdateBy, c.UpdateDateTime, c.RowVersion }).ToList();
            RadGrid1.DataSource = query;
Tags
Grid
Asked by
Anthony
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Anthony
Top achievements
Rank 1
Share this question
or