jzhu
February 21, 2023, 6:25pm
1
Hallow,
I have a date picker in a data grid column, like
after I picked up a date time, how can I got the picked date time value. I want to use the picked date time value in other place.
the codes are:
<RadzenDataGridColumn TItem="Wmds.Models.Wmdsui.TaskScheduleDto" FormatString="{0:g}" Property="ModifiedDate" SortOrder="SortOrder.Descending" TextAlign="TextAlign.Center" Title="Modified Date" Width="200px" Filterable="true" FilterProperty="ModifiedDate">
</RadzenDataGridColumn>
Thank you!
John
enchev
February 22, 2023, 9:15am
2
Hi @jzhu ,
This DatePicker will set the respective DataGrid column FilterValue property. If you have set @ref
for the DataGrid, you can access it like this for example: grid.ColumnsCollection[3].FilterValue
. Since the value of this property is object you can cast it to DateTime when needed.
jzhu
February 24, 2023, 4:28pm
3
Thank you for help!
I have another question: when I click the datepicker and make a selection, do I have a way to call a function and pass the parameters to the function in the xxx.razor.cs file?
Thank you again!
John
enchev
February 24, 2023, 4:41pm
4
You can use LoadData event if you want to get new data according to the new filter - check our demos for reference.
jzhu
February 24, 2023, 5:59pm
5
Thank you, Enchev,
I only want to call a function that is created in xxx.razor.cs,
the code in razor:
RadzenDataGridColumn
TItem="Wmds.Models.Wmdsui.TaskScheduleDto" FormatString="
{0:g}" Property="ModifiedDate" SortOrder="SortOrder.Descending"
TextAlign="TextAlign.Center" Title="Modified Date" Width="200px"
Filterable="true" FilterProperty="ModifiedDate" >
</RadzenDataGridColumn
I have a function in xxx.razor.cs,
protected async System.Threading.Tasks.Task OnModifiedDateSelectionAsync(object value)
{
// DateTime dt = value.
}
how to call this function from razor RadzenDataGridColumn.
I don't need to reload datagrid,
thank you!
John
enchev
February 25, 2023, 6:46am
6
There is another Filter event that can be used for such functions calls.