Column order for JqGrid

Dec 6, 2011 at 8:32 AM

Hi!
I'm using your JqGrid helper with a derived model class.
However, derived members appears at first columns, while i would like to choose my personal order.

I was not able to find a "order" property to specify column order.
Got some ideas or suggestions?

Coordinator
Dec 6, 2011 at 2:58 PM

Hi,

If you are using ASP.NET MVC 3 with standard DataAnnotationsModelMetadataProvider the Order property of Display DataAnnotation should do the trick. Please let me know if it's not working.

Regards,
Tomasz Pęczek

Dec 7, 2011 at 2:43 PM

Hello,

i tried your suggestion but looks like it works only halfy!
Using Order named parameter of display attribute, columns header are now correctly set, but data cells are not moved according to new specification.

Example:

    public class RowDocDett
    {
        [Required(ErrorMessage = "Campo obbligatorio"), Display(Name = "Codice", Order = 1), JqGridColumnLayout(Width = 125), JqGridColumnEditable(false)]
        public string Codice { get; set; }
        [Required(ErrorMessage = "Campo obbligatorio"), Display(Name = "Descrizione", Order = 2), JqGridColumnLayout(Width = 400), JqGridColumnEditable(false)]
        public string Descrizione { get; set; }
        [Required(ErrorMessage = "Campo obbligatorio"), Display(Name = "Udm", Order = 3), JqGridColumnLayout(Width = 85), JqGridColumnEditable(false)]
        public string Udm { get; set; }
        [Required(ErrorMessage = "Campo obbligatorio"), RegularExpression(@"^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$", ErrorMessage = "RexExp fallita"), Display(Name = "Qta", Order = 4), JqGridColumnLayout(Width = 42, Alignment = Lib.Web.Mvc.JQuery.JqGrid.JqGridAlignments.Right), JqGridColumnEditable(true, CustomValidation = true, CustomValidationFunction = "ValidateDecimal")]
        public decimal Quantità { get; set; }
        [Required(ErrorMessage = "Campo obbligatorio"), RegularExpression(@"^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$", ErrorMessage = "RexExp fallita"), Display(Name = "Prezzo", Order = 5), JqGridColumnLayout(Width = 42, Alignment = Lib.Web.Mvc.JQuery.JqGrid.JqGridAlignments.Right), JqGridColumnEditable(true, CustomValidation = true, CustomValidationFunction = "ValidateDecimal")]
        public decimal Prezzo { get; set; }
        [Required(ErrorMessage = "Campo obbligatorio"), RegularExpression(@"^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$", ErrorMessage = "RexExp fallita"), Display(Name = "Totale", Order = 6), JqGridColumnLayout(Width = 50, Alignment = Lib.Web.Mvc.JQuery.JqGrid.JqGridAlignments.Right), JqGridColumnEditable(true, CustomValidation = true, CustomValidationFunction = "ValidateDecimal")]
        public decimal Totale { get; set; }
    }

    public class RowDocDett_ag : RowDocDett
    {
        [JqGridColumnLayout(Width = 42, Alignment = Lib.Web.Mvc.JQuery.JqGrid.JqGridAlignments.Right)]
        [Display(Name = "Prz. listino", Order = 7)]
        public decimal PrzList { get; set; }
    }

I see PrzList cells data under Codice column header!

It does not work even using 0 based order.
Thank you for your support,

Coordinator
Dec 7, 2011 at 8:26 PM

Bug has been identified and fixed in Lib.Web.Mvc v4.3.1

Coordinator
Dec 7, 2011 at 8:27 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 7, 2011 at 9:28 PM

Perfect! Thank you for your prompt fix

Jun 17, 2014 at 1:24 PM
Hi! I'm using Lib.Web.Mvc v6.4.1 and have same problem with ordering columns described by XVincentX.

Could you verify the error again and to fix it?

Thank you.
Coordinator
Jun 18, 2014 at 8:50 PM
Hi,

Sorry for the late response, I've been travelling a lot recently. It is unlikely that this bug has returned (as it has been fixed more than two years ago) unless something changed in Framework. I will try to look into this in next two days and verify what is happening.