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

Latest Date column

5 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shehab
Top achievements
Rank 1
Shehab asked on 01 Jul 2008, 06:45 PM
Hello everyone,

I am working on creating a column in a grid; that colum should be the later date out of two other date columns and then sort the grid by that new column.

here is what I have for the two columns:
                    <radg:GridBoundColumn UniqueName="DateAdministered" SortExpression="DateAdministered" HeaderText="First Fill Date" DataField="DateAdministered" DataFormatString='{0: MM/dd/yyyy}'>  
                        <HeaderStyle Wrap="False" HorizontalAlign="left"/>  
                        <ItemStyle Width="140px" /> 
                    </radg:GridBoundColumn> 
                    <radg:GridBoundColumn UniqueName="RefillDate" SortExpression="RefillDate" HeaderText="Last Refill Date" DataField="RefillDate" DataFormatString='{0:MM/dd/yyyy}'>  
                        <HeaderStyle Wrap="False" HorizontalAlign="left"/>  
                        <ItemStyle Width="140px" /> 
                    </radg:GridBoundColumn>       
 
I am just wondering how the third column will be build and if it should calculate the later date of the other two columns in the Grid DataItemBound.

Please let me know if any ideas.

Thank you in advance,
Shehab

5 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 02 Jul 2008, 10:40 AM
Hello Shehab,

The third column can be a template column, with a Label or a datepicker control. Teh value can be calculated in the ItemDataBound event handler, or in the PreRender event.
Additionally, you can calculate it statically, in the aspx, via a code block.
I hope this is a suitable option for you.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Shehab
Top achievements
Rank 1
answered on 02 Jul 2008, 11:09 AM
Hi Yavor,

Thank you for your replay, I thought of that too and created a template column and calculated the later date in the itemdatabound but how would I sort the grid upon to this template column now that it will be built in itemdatabound?

Thanks,
Shehab
0
Yavor
Telerik team
answered on 02 Jul 2008, 11:20 AM
Hello Shehab,

The grid can only sort a column, if the column is included in the original database, and a proper fieldName is passed to the grid for it. In the example that you mentioned, the grid will only be able to sort the template column, if you set the sortExpression to point to any of the columns in the original datasource.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Shehab
Top achievements
Rank 1
answered on 02 Jul 2008, 11:36 AM
I am sorry, I am not sure if you meant there is a way to sort the gird by the template column or it will only sort a column coming for the database? And if there is a way, do you have an example for me?

Thanks,
Shehab
0
Yavor
Telerik team
answered on 02 Jul 2008, 11:44 AM
Hello Shehab,

In this particular case, because the column will be derived from two other columns, the control will not be able to sort on it (on the result obtained from performing calculations on the two columns).

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Shehab
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Shehab
Top achievements
Rank 1
Share this question
or