Jump to content

Change Datalist Widget column width


Sam P

Recommended Posts

I have brought together a Widget to display our high priority requests in a datalist but wondered if there is a way I can specify column width?    Summary seems to be preset very wide and is taking a lot of space that could nicely be used to prevent the word wrap on some of the other fields.  Thank you

image.thumb.png.998d1cb1a7208966e187853f79160622.png

Link to comment
Share on other sites

Hi @Sam P,

I'm not sure if this will help at all, but thought it was worth mentioning....

I've had this issue, though in your screenshot, I cannot tell if you have other request details further below the screenshot, where the the length of Summary is as long as the arrows you've drawn on the screenshot, but my workaround was to shorten the summary within the SQL.

CASE
	WHEN LENGTH(h_summary) > 140 THEN CONCAT(LEFT(h_summary,140),'...') 
	ELSE h_summary 
END Summary

If the length of the summary is 140 or more, just display the first 140 characters, then append the 3 dots to the end "..." to indicate it's been truncated, otherwise display the summary as normal.

You can change the number 140 to something small if required, to truncate it further.

Link to comment
Share on other sites

Hi @Sam P,

No worries at all, here is the amended SQL at the bottom.

  • I did make a tweak to how the Status is displayed, personally, having a CASE statement is easier on the eyes and on the processing of the SQL on the system. Embedding multiple REPLACE functions does take up more processing power as it would have to go through each function.

    A CASE statement works similarly to how and IF statement works in many other languages, and only evaluates on the matching value, using less processing power.

    IF (<CONDITION 1>) THEN VALUE
    ELSE IF (<CONDITION 2>) THEN VALUE 2
    ELSE OTHER VALUE
    END IF
     
  • In my own testing to make sure I could get this working, I changed h_fk_priorityname to do a wildcard % search ( h_fk_priorityname like 'P2%' ) but you might prefer to be more specific as per your screenshot ( h_fk_priorityname = 'P2 - High (2 Days)' ). It's a matter of preference.

Here is the amended SQL:

select	h_source_type       as Source, 
    	h_pk_reference      as Reference, 
    	h_datelogged        as "Date Logged",
    	CASE h_status
        	WHEN 'status.new'       then 'New'
            WHEN 'status.open'      then 'Open'
            WHEN 'status.onHold'    then 'On Hold'
            WHEN 'status.resolved'  then 'Resolved'
            WHEN 'status.closed'    then 'Closed'
            WHEN 'status.cancelled' then 'Cancelled'
	    END                 as Status,
    	CASE
            WHEN LENGTH(h_summary) > 50 THEN CONCAT(LEFT(h_summary,50),'...') 
            ELSE h_summary 
        END                 as Summary,
    	h_fk_priorityname   as Priority, 
    	h_fk_team_name      as Team
from	h_itsm_requests 
where	h_status IN ('status.new', 'status.onhold', 'status.open') 
and		h_requestType = 'Incident'
and		h_fk_priorityname like 'P2%' 
ORDER BY h_datelogged DESC

The code block on the forums doesn't appear to match the source formatting very well in case you are wondering why some of the code is out of alignment.

II hope this helps :)

Thanks,

Samuel

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...