question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

xyzGrid; Quicksearch, Columns with Dateformatter not properly searchable

See original GitHub issue

Hi JaiQ,

John Ranger here again 😃

I have a grid where I have 3 columns (DateTime type in xyzRow.cs) where I have a dateformatter like this:

xyzColumns.cs

...
[DateFormatter(DisplayFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime TimestampStart { get; set; }

I would like now to be able to Quicksearch These visible Dates like “2016-02” or “2016-02-01” but it only allows me to search either for “2016” or “02” but I cannot Combine it like the above “2016-02”.

I tried with putting the dateformatter from the xyzColumns.cs to xyzRow.cs but without success.

Is this at all achievable and if yes, how would I do this? (I didn’t find a hint about this in the DEV-Guide)

Thanks for your help and

with Kind regards,

John

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
volkanceylancommented, Mar 1, 2016

Yes, expression attribute and most other is close to SQL as possible. Just it might not be database agnostic but i’m planning to add something like Expression(“SqlServer”, “…”), Expression(“MySql”, “…”) etc to handle dialect specific cases.

Btw, this would probably be slow with big tables but you’re the database admin, so i suppose in that case you’ll come up with a calculated field and index on it.

Anyway glad to help, especially users who cares about helping others like you do 😉

1reaction
JohnRangercommented, Mar 1, 2016

To all wo reads this, I have solved the additional (hidden) quicksearch addon-fields like this (Suggestion of Volkan Ceylan):

In the xyzRow.cs, add a new stringfield like this:



        [DisplayName("Timestamp Job Generated"), Expression("convert(varchar(19),Timestamp_JobGenerated,120)"), QuickSearch]
        public String TimestampJobGenerated_search
        {
            get { return Fields.TimestampJobGenerated_search[this]; }
            set { Fields.TimestampJobGenerated_search[this] = value; }
        }

where the convert(varchar(19),Timestamp_JobGenerated,120) is the command which will be used within the resulting SQL query. Timestamp_JobGenerated is the SQL table field where the original datetime value is stored.

The resulting query in my case Looks like this (when I typed 2016-02-22 in the search box:):

DECLARE @p1 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p2 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p3 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p4 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p5 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p6 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p7 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p8 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p9 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p10 NVARCHAR(4000) = '%2016-02-22%';
DECLARE @p11 NVARCHAR(4000) = '%2016-02-22%';

SELECT TOP 100 
T0.[JobId] AS [JobId],
T0.[JobTypeId] AS [JobTypeId],
T0.[UserId] AS [UserId],
T0.[JobStatusId] AS [JobStatusId],
T0.[Timestamp_Start] AS [TimestampStart],
T0.[Timestamp_End] AS [TimestampEnd],
T0.[Timestamp_JobGenerated] AS [TimestampJobGenerated],
T0.[Remarks] AS [Remarks],
T0.[Hostname] AS [Hostname],
jJobType.[JobTypeName] AS [JobTypeJobTypeName],
jUser.[DisplayName] AS [UserDisplayName],
jJobStatus.[JobStatusName] AS [JobStatusJobStatusName],
convert(varchar(19),Timestamp_JobGenerated,120) AS [TimestampJobGenerated_search] 
FROM [dbo].[Jobs] T0 
LEFT JOIN [dbo].[JobTypes] jJobType ON (jJobType.[JobTypeId] = T0.[JobTypeId]) 
LEFT JOIN [dbo].[Users] jUser ON (jUser.[UserId] = T0.[UserId]) 
LEFT JOIN [dbo].[JobStatus] jJobStatus ON (jJobStatus.[JobStatusId] = T0.[JobStatusId]) 
WHERE (((((((((((T0.[Timestamp_Start] LIKE @p1 OR T0.[Timestamp_End] LIKE @p2) OR T0.[Timestamp_JobGenerated] LIKE @p3) OR T0.[Remarks] LIKE @p4) OR T0.[Hostname] LIKE @p5) OR jJobType.[JobTypeName] LIKE @p6) OR jJobType.[Remarks] LIKE @p7) OR jUser.[Username] LIKE @p8) OR jUser.[DisplayName] LIKE @p9) OR jJobStatus.[JobStatusName] LIKE @p10) OR convert(varchar(19),Timestamp_JobGenerated,120) LIKE @p11)) 
ORDER BY T0.[Remarks], T0.[JobId];
SELECT count(*)  
FROM [dbo].[Jobs] T0 
LEFT JOIN [dbo].[JobTypes] jJobType ON (jJobType.[JobTypeId] = T0.[JobTypeId]) 
LEFT JOIN [dbo].[Users] jUser ON (jUser.[UserId] = T0.[UserId]) 
LEFT JOIN [dbo].[JobStatus] jJobStatus ON (jJobStatus.[JobStatusId] = T0.[JobStatusId]) 
WHERE (((((((((((T0.[Timestamp_Start] LIKE @p1 OR T0.[Timestamp_End] LIKE @p2) OR T0.[Timestamp_JobGenerated] LIKE @p3) OR T0.[Remarks] LIKE @p4) OR T0.[Hostname] LIKE @p5) OR jJobType.[JobTypeName] LIKE @p6) OR jJobType.[Remarks] LIKE @p7) OR jUser.[Username] LIKE @p8) OR jUser.[DisplayName] LIKE @p9) OR jJobStatus.[JobStatusName] LIKE @p10) OR convert(varchar(19),Timestamp_JobGenerated,120) LIKE @p11))

Hope this helps somebody.

With Kind regards,

John

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect date format when using text to columns
I've got an issue when I am importing a text file and using the text to columns function where its not recoginsing the...
Read more >
jqGrid search formated date using toolbar
When a search date is entered which contain only month and day the year is missing and the search is performed on the...
Read more >
GridColumn format not working in KendoReact
Hello, Eric, Joe is right. In order to apply the correct format, the Grid expected the values inside the column to be valid...
Read more >
Unable to get Excel to recognise date in column
Under column data format choose Date and select MDY in the adjacent combo box and click Finish. Now you got date values (i.e....
Read more >
Help With Date Formatting - Microsoft Power BI Community
Hello, I was hoping to get some help regarding changing data type for one of my columns in PowerBI to a date data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found