RadListView Modify Edited Value

3 posts, 0 answers
  1. Brandon
    Brandon avatar
    21 posts
    Member since:
    Jan 2019

    Posted 22 Jan 2019 Link to this post

    I have a column with which get's edited using the ListViewDateTimeEditor.

    The question is, how do I format the value that gets submitted to the ListView.

    To be clear, I have already formatted the ListViewDateTimeEditor to use the following: 

    Dim Editor As New ListViewDateTimeEditor
    TryCast(Editor.EditorElement, BaseDateTimeEditorElement).Format = DateTimePickerFormat.Custom
    TryCast(Editor.EditorElement, BaseDateTimeEditorElement).CustomFormat = "MM/dd/yyyy"
    e.Editor = Editor


    Even with this formatting, it still submits the full DateTime to the ListView when finished editing.  How do I make it output only the formatted Date value, without the Time?

  2. Brandon
    Brandon avatar
    21 posts
    Member since:
    Jan 2019

    Posted 22 Jan 2019 Link to this post

    Not sure if it's the proper way, but I figured out at least one way to do it.

    I captured and processed it in the ListView's ItemEdited event.

    Private Sub lvEquip_ItemEdited(sender As Object, e As ListViewItemEditedEventArgs) Handles lvEquip.ItemEdited
        If e.VisualItem.Data.ListView.CurrentColumn.Name = "Col23" Then
            Dim DT As DateTime
            DateTime.TryParse(e.VisualItem.Data("Col23"), DT)
            e.VisualItem.Data("Col23") = DT.ToShortDateString
        End If
    End Sub
  3. Dimitar
    Dimitar avatar
    2983 posts

    Posted 23 Jan 2019 Link to this post

    Hi Brandon,

    Your appraoch is ok if you are storing the data as a string. If you are storing a DateTime object you can use the CellFormatting event and change the text of the cell which would not affect the actual value:
    Private Sub RadListView1_CellFormatting(ByVal sender As Object, ByVal e As ListViewCellFormattingEventArgs)
        Dim cell As DetailListViewDataCellElement = TryCast(e.CellElement, DetailListViewDataCellElement)
        If cell IsNot Nothing AndAlso cell.Data.Name = "Date" Then
            Dim value As Date = CDate(cell.Row("Date"))
            cell.Text = value.ToShortDateString()
        End If
    End Sub

    I hope this will be useful. Let me know if you have additional questions.

    Progress Telerik
    Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top