Fix: jqGrid search operator menu items jumping around on hover

A colleague noticed earlier on today, that on the Chrome browser they were using, the search operator menu items of a jqGrid on a web app’s UI were jumping around on hover, making it practically impossible to select one.

image   image

Seems this had started occurring on that ASP.net MVC web application, after a recent update to the latest jQuery-UI NuGet package.

Probably the issue wouldn’t occur if it wasn’t using the older free version of jqGrid. Will probably transition it eventually to free-jqGrid, the free fork (and quite evolved since forked) of the older free version of jqGrid, since jqGrid’s newer version is now commercial.

For the time being, I ended up adding this fix to Content/Site.css of the ASP.net MVC webapp:

/* jqGrid search operator menu item hover (uses jQuey-UI) */

a.ui-corner-all.g-menu-item.ui-state-hover {
    border: 1px #cccccc !important; /* fix for Chrome: removed "solid" (was causing hovered items to resize and menu to relayout, making it too hard to select them */
    /*border: 1px solid #cccccc;*/ /* this is used by jQuery-UI for .ui-state-hover */

    color: blue; /* showing blue color for hovered over menu text, should show better than a hover border since selected item already has a border itself */
}

This also has the added extra that on hover it shows the hovered item’s text in blue:

image

HowTo: change color of validation messages in ASP.net MVC

If you need to customize the colors (or do more restyling) of validation messages in ASP.net MVC, the following snippet from a discussion on ASP.net forums should be useful:

Add to Content/Site.css:

/* styles for validation helpers */

.field-validation-error {
    color: #b94a48;
}

.field-validation-valid {
    display: none;
}

input.input-validation-error {
    border: 1px solid #b94a48;
}

select.input-validation-error {
    border: 1px solid #b94a48;
}

input[type="checkbox"].input-validation-error {
    border: 0 none;
}

.validation-summary-errors {
    color: #b94a48;
}

.validation-summary-valid {
    display: none;
}

Other useful replies from there:

@Html.ValidationSummary(true,"",new {@style= "color: red"})

The method for MVC 5 + Bootstrap is:
@Html.ValidationSummary(true, "", new { @class = "text-danger" })

OpenStreetMaps as an alternative to Google Maps in Joomla!

If you use Joomla! (CMS / Content Management System), you could switch to the free OpenStreetMaps instead of the recently-turned-much-more-expensive Google Maps, thanks to the OSModul extension for Joomla!:

https://extensions.joomla.org/profile/extension/maps-a-weather/maps-a-locations/osmodul/

At the bottom of this page there is an example that uses a pin icon similar to how a location would appear in Google Maps. And here is an example with multiple pins (shown as ships).

A shortcoming in comparison to Google Maps is that OpenStreetMaps doesn’t show by itself many Points of Interest (POI) on the map for one to get oriented easier. For example the maps for the location at (38.29399, 21.78592) shows up a little bare: https://www.openstreetmap.org/query?lat=38.29399&lon=21.78592 compared to the same location shown on Google Maps: https://www.google.com/maps/place/38°17’38.4"N+21°47’09.3"E/@38.29399,21.78592

So it is best to add some such characteristic locations apart from one’s location pin, as shown at: https://gitlab.com/schlumpf/osmodul/wikis/Additional%20Markers%20Pins

More information on the OSModul extension for Joomla! can be found at:

https://gitlab.com/schlumpf/osmodul

https://gitlab.com/schlumpf/osmodul/wikis/How%20to%20use

HowTo: Fix DVD/CD with Live filesystem (Packet/UDF) on Windows

The other day I found how easy it is to use a Live CD/DVD (where packet writing occurs when adding stuff) instead of a Mastered one (where all is kept to be written when you close the disk) on Windows.

It feels more like using a USB flash disk and should be more safe regarding losing data in the long run if you want to keep some file archive. In theory at least, since there are cases the live disk last write operation may fail and it may appear as an unreadable disk after one, making funny noises when you insert it and freezing for long time periods Windows Explorer when you try to access it.

However, the UDF filesystem that it uses keeps multiple VAT tables for the blocks written to the disk, which means it can be restored to the last workable state of the disk (you might still lose data from the last block I guess, but you’ll have access to the rest of the files you had written to the disk). For any files you find missing, you can try file recovery software with deep search option, like ISOBuster.

To restore such a disk back to working state, on Windows 10 you can right click the Start menu button and from the context (popup) menu shown, you can select to run PowerShell as Administrator. Then you can write CMD and press ENTER. The classic command-line shell (DOS syntax) will open up, where you should type-in chkdsk /f e: (replacing e: with the letter of the drive where the problematic disk has been inserted – can find that one easily from Windows Explorer / My Computer) and press ENTER again.

The disk should be detected as being of UDF format and the disk checking (chkdsk) command will check for a valid VAT on the last written block and if it can’t will try to revert the media to a previous state, before the corruption occurred by placing at the the end of the disk the last valid VAT.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\WINDOWS\system32> cmd
Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. Με επιφύλαξη κάθε νόμιμου δικαιώματος.

C:\WINDOWS\system32>chkdsk /f e:
The type of the file system is UDF.
Volume Μουσική is UDF version 2.01.

Chkdsk is running on media that does not support writes in place.
On such media chkdsk operation is limited to verifying the presence
of a valid VAT on the last written block and if necessary searching
for the last valid VAT and placing it at the end of the disk.
This could revert the media to a previous state before the corruption
occured.

Chkdsk could not find a valid VAT at the end of the volume.

CHKDSK is searching for a valid VAT …

And after some ages (stayed at 0% for some time and then took around a day progressing slowly on my machine for a DVD) you’ll hopefully see something like:

Search for VAT completed.
Chkdsk is copying last valid VAT at block 1722719 to the end of the
volume. This will revert the volume to its state at 01:13 on
10/09/2018.

Windows has made corrections to the file system.
No further action is required.

   4595200 KB total disk space.
    222240 KB available on disk.

      2048 bytes in each allocation unit.
   2297600 total allocation units on disk.
    111120 allocation units available on disk.

Then type exit followed by ENTER key twice to exit the command processor (cmd) and PowerShell. This will close the console window.

C:\WINDOWS\system32>exit
PS C:\WINDOWS\system32> exit

Enjoy your disk with its files again, hopefully all of them… Plus you’ll be able to add more files to the disk, which could have even been near to empty when the corruption had occurred. Note that when you’re finished and don’t want to write anymore files to the disk, you can right click it and close the session, so that it can be readable on more systems.

HowTo: include MVC model property Display name in Required validation message

Just came across this validation error display in an MVC app I’ve recently started maintaining. The required input field validation seemed to not be localized, resulting in a mixed English and Greek (from the field’s Display name) message:

image

Looking at the MVC model I noticed they were using [Required] attributes for the userName and password properties, together with [Display(Name = "…")] for the displayed property title

public class LoginModel
  {
     [Required]
     [Display(Name = "Όνομα Χρήστη")]
     public string userName { get; set; }

     [Required]
     [DataType(DataType.Password)]
     [Display(Name = "Κωδικός")]
     public string password { get; set; }

     //…

That was changed to:

public class LoginModel
  {
     [Required(ErrorMessage = "Το {0} είναι απαραίτητο.")]
     [Display(Name = "Όνομα Χρήστη")]
     public string userName { get; set; }

     [Required(ErrorMessage = "Το {0} είναι απαραίτητο.")]
     [DataType(DataType.Password)]
     [Display(Name = "Κωδικός")]
     public string password { get; set; }

resulting in a fully localized validation error message with the respective property’s Display name auto-inserted in the validation ErrorMessage, thanks to the {0} used in the message string:

image

Note there’s also the lazy route like in this property:

[Display(Name = "Περίοδος Εγγύησης(Έτη):")]
[Required(ErrorMessage = "Απαραίτητο πεδίο")]
public int warrantyPeriod { get; set; }

where you just say something like “Required field” in the localized error message. This however will work only when you always show the error message next to the input field that fails to pass validation.

If you want to also show a validation summary say at the beginning and/or the end of the page (depending on where your submit button is), you’ll end up with an error summary that may just contain multiple entries of “Required field” text without any indication on what field it was (which would be practically useless that is).

Note that sometimes due to lack of space in a webpage (say if you have lots of input fields in a grid) you can only show say red “*” near input fields that have validation errors and explain them more in the tooltips and in an error summary control.

Even better you can use resource strings to avoid error message string duplication. That approach, though a bit more verbose as implemented in ASP.net means easier centralized maintenance and localization from a per locale/language resource file and less typos or slightly different error messages for the same thing. See example and related screenshots at https://stackoverflow.com/a/22849638

Fix: jQuery’s jqGrid search UI custom styling

Lately, I’ve got the task of maintaining/extending an ASP.net MVC web application that is using jQuery’s jqGrid for data grids on its UI. First thing I noticed was how confusing the search UI on the grid’s header was:

image

Those symbols on the left-side of each column’s searchbox are for the type of search (e.g. contains, doesn’t contain, equals, starts with, doesn’t start with, ends with, doesn’t end with).

Bit too many options and using programming-related symbols that probably intimidate several users in my opinion:

image

But the worse is the “x” button (that clears the searchbox) on the right of each searchbox, that combined with the search-type symbols makes the whole search bar look like some strange mathematical expression.

So using the browser dev tools (F12) and some CSS rules I quickly restyled that search bar to make it more appealing UI/UX wise:

image

Added a border around the “x” button that clears the searchbox and offseted using a negative margin so that the searchbox and it fuse together visually on their sides. Also made the search-type symbol (that opens the search-type selection popup when clicked) of lighter color. It may look a bit-like some disabled thing like that, but at least it should confuse average users less with its use of technical symbols like that.

Just need to add the rules above at the ASP.net MVC app’s Site.css (probably to be found at the Content subfolder of the webapp) and remember to press F5/Refresh in one’s browser in case the old styling still appears due to caching.

Update #1:

I noticed on older versions of Windows (other than Windows 10 that is) that bevels were showing at the text inputs, leading to this ugly effect:

image

So I had to add some more rules to remove the bevel borders and use a consistent border color.

Removing the bevels seemed to also remove the inner padding of the text inputs, so added a padding of 2px and some box-sizing rules to make sure the padding doesn’t affect the input’s size.

/* OS-independent styling for input and textarea borders */
textarea,
input[type="text"],
input[type="password"] {
    border-style: solid;
    border-width: 1px;
    border-color: gray;
    padding: 2px;
    -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
    -moz-box-sizing: border-box; /* Firefox, other Gecko */
    box-sizing: border-box; /* Opera/IE 8+ */
}

Update #2:

After recently updating some jQuery related NuGet packages in that ASP.net project, I noticed the [x] button was showing a bit higher up at the bottom compared to the search box. The fix to that was to add padding-bottom: 1px; at the CSS declaration for clearsearchclass in Content/Site.css

a.clearsearchclass {
    border-width: 1px;
    border-style: solid;
    /* border-left-style: none; */
    margin-left: -3px;
    padding-bottom: 1px; /* seems to be needed with newer jQuery.UI */
    background: whitesmoke;
    border-color: gray;
}

Categories: Posts Tags: , , , , , , , , ,
%d bloggers like this: