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

[Solved] RadGridView

7 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Raviraj
Top achievements
Rank 1
Raviraj asked on 14 Feb 2011, 10:49 PM
I Have a Collection with StartDateTime and Duration as Properties. I want to bind EndDateTime to the GridViewDataColumn. I have first used Converter to and passed StartDateTime as value object and was trying to bind the Converter Parameter with Duration so that i could return StartDateTime.AddHours(Duration) but i cannot bind the Converter paramter.

so next i tried using the RowLoaded event where i want to dynamically put the text on the GridViewDataColumn which am not able to do it.

See below snippet

<

 

 

telerik:GridViewDataColumn x:Name="endDateTime" Header="End DateTime" TextWrapping="Wrap">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock x:Name="txtEndDateTime"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

 

private

 

 

void grid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{

if

 

 

(e.Row is GridViewRow)

    G
ridViewRow gvr = e.Row; 
    
GAAP_NRCPower_PI_Planned_Event objEvent = e.DataElement as GAAP_NRCPower_PI_Planned_Event
    DateTime endDateTime = objEvent.Start_DateTime.AddHours(objEvent.Duration);
   (gvr.FindName("txtEndDateTime") as TextBlock)--> this throws error because it is getting null  
}
}

 

 

 

 

 

 

 

 

 

Thanks in Advance.

 

 

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 15 Feb 2011, 07:38 AM
Hi Raviraj,

As far as I could understand, you have two properties - StartDateTime and Duration and you want to calculate the EndDataTime based on the previous to and display it in a column. Is that correct ? If yes, you may benefit from the GridViewExpressionColumn
 

Regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Raviraj
Top achievements
Rank 1
answered on 15 Feb 2011, 08:56 AM
Hi,
   Thank you very much for your reply...

    1) Is there any event where i have to write this? or should i write this when am Loading the UserControl??
Expression<Func<Products, DateTime>> expression = prod => prod.StartDateTime.AddHours(prod.Duration);
GridViewExpressionColumn column =
this.RadGridView1.Columns["TotalValue"] as GridViewExpressionColumn;
column.Expression = expression;

And 2nd question i have is what can i do if the StartDateTime and Duration are coming from two different List's which can be joined with eventID property in both the List's.

Above two are two different questions

--
Thanks
Raviraj.
0
Maya
Telerik team
answered on 15 Feb 2011, 04:09 PM
Hello Raviraj,

The part of the definition of the GridViewExpressionColumn in the code-behind may be set during the initialization (after the InitiazeComponent()). As far as the second question is concerned, I would need a bit more details about the exact settings of your grid and mainly about the implementation of your business objects. How exactly do you get the values for the StartDataTime and Duration ? How do you connect them with the eventID property ? Generally, any additional information and code-snippets would be helpful.

 

Best wishes,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Raviraj
Top achievements
Rank 1
answered on 15 Feb 2011, 06:01 PM
Hi,
      Grid should display 5 columns (EventName, EventStartDateTime, EventDescription, EventNotes, EventEndDateTime)

where First 4 columns come from EventDetails List which has (EventID, EventName, EventStartDateTime,EventDescription, EventNotes) Properties.

And second list is EventLogList which has  (EventId, EventDuration) Properties.

So Now..What i need is to on grid first 4 columns will come from EventDetailsList and the 5th Column EventEndDateTime should be a computed column based on the relation between two LISTS and related with EventID.


0
Maya
Telerik team
answered on 16 Feb 2011, 01:42 PM
Hello Raviraj,

I am sending you a sample project illustrating how you may achieve the desired result. 

Regards,
Maya
the Telerik team
0
Raviraj
Top achievements
Rank 1
answered on 16 Feb 2011, 06:24 PM
Hi,

          Thank you soo much thats perfectly working...

1) When i am using the ExpressionColumn i am not able to see the Filters enabled on the Column. Is there anything specific i need to do enable that Filter.

2) I want to see a ToolTip onFocus each Row of a RadGridView. That Tooltip should display Notes Column from the List binded to the RadGridView.


--
Thanks
Raviraj.
0
Maya
Telerik team
answered on 16 Feb 2011, 08:00 PM
Hello Raviraj,

You may take a look at this forum thread considering filtering of a GridViewExpressionColumn. As far as the ToolTip is concerned, you may run through this forum thread.
 

Regards,
Maya
the Telerik team
Tags
GridView
Asked by
Raviraj
Top achievements
Rank 1
Answers by
Maya
Telerik team
Raviraj
Top achievements
Rank 1
Share this question
or