FlexGrid row and column cssClass issues

Posted by: elogsdon on 9 September 2020, 1:49 am EST

    • Post Options:
    • Link

    Posted 9 September 2020, 1:49 am EST

    I am having two issues in setting formatting on a specific column or row using cssClass on a FlexGrid.

    A screen shot of the grid is attached.

    First the column. If the column is read only, I have set the cssClass on a column to a css class that sets the backgroud color to orange. Only every other row is showing with the new color. I have specified AlternatingRowStep(0) on the FlexGrid definition.

    Second, the row. I am setting the background color to magenta based on a button click. Visually I can see the row flash briefly as magenta before resuming the default color. This is done in a javascript invoked by the button.

    The FlexGrid definition:

        @(Html.C1().FlexGrid().Id("policyGrid")
                .CssClass("custom")
                .IsReadOnly(true)
                .SortingType(C1.Web.Mvc.Grid.AllowSorting.SingleColumn)
                .Bind(ib => ib.Update(Url.Action("GridUpdate")).OnClientQueryComplete("Complete")
                .Create(Url.Action("GridCreate"))
                .Delete(Url.Action("GridDelete"))
                .DisableServerRead(true)
                .Bind(Model.Policies))
                .AutoGenerateColumns(false)
                .AlternatingRowStep(0)
                .IsReadOnly(false)
                .ShowColumnFooters()
                .Columns(c =>
                {
                    foreach (var col in Model.ColumnList)
                    {
                        c.Add(col);
                    }
                })
                .AllowAddNew(true)
                .AllowDelete(true)
                .ShowErrors(true)
                .OnClientLoadedRows("fixDefaultJSAlert")
    

    The custom css:

    .custom .lb-read-only {
        background-color: orange;
    }
    
    .custom .lb-deleted {
        background-color: magenta;
    }
    

    The Javascript to set the row css from the buton click:

        function billDelete() {
            var batchEditGrid = wijmo.Control.getControl('#policyGrid');
            var cv = batchEditGrid.collectionView;
            cv.editItem(batchEditGrid.rows[batchEditGrid.selection.row].dataItem);
    
            batchEditGrid.rows[batchEditGrid.selection.row].cssClass = "lb-deleted";
    
            if (cv.currentEditItem.PolicyStatus == "D") {
                cv.currentEditItem.PolicyStatus = "A";
            }
            else if (cv.currentEditItem.PolicyStatus == "N") {
                cv.removeAt(batchEditGrid.selection.row);
            }
            else {
                cv.currentEditItem.PolicyStatus = "D";
            }
            cv.commitEdit();
        }[\code]
    
    Any further samples or clarification would be appreciated.
    
    Eric
    [img]https://gccontent.blob.core.windows.net/forum-uploads/file-dba7c78b-e9a8-4ede-8b87-0193fb88f338.png[/img]
  • Posted 9 September 2020, 10:57 pm EST

    Hello Eric,

    We are sorry we are unable to replicate the issue. Please refer to the attached sample for reference.

    Regards,

    Manish Gupta

    FlexGrid-RowColor.zip

  • Posted 11 September 2020, 1:43 am EST

    I upgraded from 2020.v1 to 2020.v2 and that resolved the column format issue.

    It seems that the issue with the row format is related to the GridUpdate routine specified in the FlexGrid definition. This returns the model containing the data to be bound.

    I am thinking that instead of setting the cssClass in the button onClick routine I need to look at the data when it is loaded and set the cssClass at that point. Should I use OnLoadedRows event handler to scan the rows or would there be a better place to do this? An example of using the event handler would help.

    Thanks.

    Eric

  • Posted 13 September 2020, 8:43 pm EST

    Hello Eric,

    Yes, the OnClientLoadedRows event would be fine in case it’s only when the data is loaded in FlexGrid.

    If you are changing the row color as the Update request is completed, then the OnClientQueryComplete event is recommended.

    Regards,

    Manish Gupta

  • Posted 14 September 2020, 7:48 am EST

    Is there documentation on the arguments to ClientQueryComplete? I assume it is Sender and Event Args, but I don’t now the contents of them.

  • Posted 14 September 2020, 4:09 pm EST

    Hello Eric,

    Yes, you are correct. OnClientQueryComplete event accepts two parameters sender and eventargs.

    First parameter is sender which is CollectionView and second parameter is QueryCompleteEventArgs. Please refer to the following code snippet for reference:

    https://www.grapecity.com/componentone/docs/mvc/online-mvc/c1.mvc.collections.QueryCompleteEventArgs.Class.html

    Regards,

    Manish Gupta

  • Posted 15 September 2020, 7:32 am EST

    Manish,

    That works well. Thanks!

    Eric

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels