c# - Is it possible to group by date, but sort by date + time in an xceed datagrid? -


i'm using (community edition) of extended wpf toolkit display records have datetime column.

<xcdg:datagridcontrol         itemssource="{binding responseinstructions, updatesourcetrigger=propertychanged}"         readonly="true"         autocreatecolumns="false"     >     <xcdg:datagridcontrol.columns>         <xcdg:column fieldname="created" title="request made">             <xcdg:column.cellcontenttemplate>                 <datatemplate>                     <textblock text="{binding stringformat=\{0:dd/mm/yy hh:mm\}}" />                 </datatemplate>             </xcdg:column.cellcontenttemplate>         </xcdg:column>         <!-- snip: other columns here... -->         <xcdg:column fieldname="notes" title="notes" width="*" />     </xcdg:datagridcontrol.columns> </xcdg:datagridcontrol> 

i'd able change grouping behaviour of datetime column groups date (i.e. ignoring time), retain default sorting ability (i.e. date, time).

if weren't need retain default sorting functionality, i'd change column datettime date. there way have cake , eat to?

eventually figured out desired can done in pure xaml also.

here sample xaml

    <xcdg:column fieldname="created"                     title="request made">         <xcdg:column.groupdescription>             <xcdg:datagridgroupdescription propertyname="created.day"/>         </xcdg:column.groupdescription>         <xcdg:column.cellcontenttemplate>             <datatemplate>                 <textblock text="{binding stringformat=\{0:dd/mm/yy hh:mm\}}" />             </datatemplate>         </xcdg:column.cellcontenttemplate>     </xcdg:column> 

result

result

in example above sorting based on full date , time grouping on day property of created(datetime) property

above example based on assumptions, not able see approach groupbydate resource groupdescription="{staticresource groupbydate}" not mentioned in question.

edit

as requested here way change aspects of group including top panel , group header

<xcdg:datagridcontrol itemssource="{binding responseinstructions}"                       readonly="true"                       autocreatecolumns="false">     <xcdg:datagridcontrol.resources>         <style targettype="{x:type xcdg:groupbyitem}">             <style.triggers>                 <datatrigger binding="{binding title}"                              value="created.date">                     <setter property="content"                             value="request made" />                 </datatrigger>             </style.triggers>         </style>         <datatemplate datatype="{x:type xcdg:group}">             <stackpanel orientation="horizontal">                 <textblock text="{binding value,stringformat=dd/mm/yy}" />                 <textblock text=": " />                 <textblock text="{binding items.count}" />                 <textblock text=" request(s)" />             </stackpanel>         </datatemplate>     </xcdg:datagridcontrol.resources>     <xcdg:datagridcontrol.columns>         <xcdg:column fieldname="created"                      title="request made">             <xcdg:column.groupdescription>                 <xcdg:datagridgroupdescription propertyname="created.date" />             </xcdg:column.groupdescription>             <xcdg:column.cellcontenttemplate>                 <datatemplate>                     <textblock text="{binding stringformat=\{0:dd/mm/yy hh:mm\}}" />                 </datatemplate>             </xcdg:column.cellcontenttemplate>         </xcdg:column>         <!-- snip: other columns here... -->         <xcdg:column fieldname="notes"                      title="notes"                      width="*" />     </xcdg:datagridcontrol.columns> </xcdg:datagridcontrol> 

result

result

i have introduced 1 style top panel , data template group header. have used data triggers in style set custom title seems data-grid has own mechanism retrieve group title. have modified group property day date, day not correct day not date.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -