Query data from date range is a common demand, but the Property may not show in main grid. Therefore, users must use "Advanced Search" in order to query these "hidden Property" (like Figure 1).
"Advanced Search" should satisfy most of demands. But it is not friendly for users due to the search option contains all Properties.
Here propose an alternative solution for easily querying date interval, please follow the steps as follow:
Although there are two "useless" Properties (permanently no data), users can easily enter their query criteria in "Simple Search" (see Figure 2). It should be more friendly way for users to query data from date range.
Figure 1 |
"Advanced Search" should satisfy most of demands. But it is not friendly for users due to the search option contains all Properties.
Here propose an alternative solution for easily querying date interval, please follow the steps as follow:
- Create "Begin Date" and "End Date" Property with "Date" data type.
- Create a server side Method with below code:
Const strQueryProp As String = "created_on" Dim strBegin As String = Me.getProperty("_begin","") Dim strEnd As String = Me.getProperty("_end","") Me.removeProperty("_begin") Me.removeProperty("_end") If Not String.IsNullOrEmpty(strBegin) Then strBegin = RegularExpressions.Regex.Split(strBegin," and ")(0) Me.node.InnerXml &= "<" & strQueryProp & " condition=""ge"">" & strBegin & "</" & strQueryProp & ">" End If If Not String.IsNullOrEmpty(strEnd) Then strEnd = RegularExpressions.Regex.Split(strEnd," and ")(1) Me.node.InnerXml &= "<" & strQueryProp & " condition=""le"">" & strEnd & "</" & strQueryProp & ">" End If Return Me
- Add above Method to Server Events of ItemType with "OnBeforeGet" event.
Although there are two "useless" Properties (permanently no data), users can easily enter their query criteria in "Simple Search" (see Figure 2). It should be more friendly way for users to query data from date range.
Figure 2 |
Comments
Post a Comment