asp.net-mvcinfragisticsignite-uiiggrid

ASP.Net MVC Infragistics igGrid - readonly attributes for updating a record, non-readonly attributes for adding a record


Hello Stackoverflow community,

I'm using an ASP.Net MVC Infragistics igGrid. I want my grid to have following behavior. If I add a new record to my igGrid, I want all my attributes / columns of my grid to be editable.

When I want to update a record of my igGrid, I want some attributes / columns to be readonly. I have tried setting some of my columns to read only. This solved my problem

when i want to update a record. But when I want to add a record, theses attributes are now readonly.

enter image description here

Is there a way to set the read only attributes separately for adding and editing a record?

thank you very much for the help.

enter image description here


Solution

  • This is what I use.It works with igTreeGrid too. You can tweak it from here on :

    editRowStarted: function (evt, ui) {
        console.log("editRowStarted");
    
        columnsToHide = ["transactionDate", "bankAccountId","distributionDescription"];
        $("tr[data-new-row] td").each(function () {
            for (j = 0; j < columnsToHide.length; j++) {
                var description = $(this).attr('aria-describedBy');
                if (description.indexOf(columnsToHide[j]) > 0) {
                    console.log("Hiding : " + description);
                    $(this).css('visibility', 'hidden');
                }
            }
        });
    },
    

    This is for hiding some of the filters in a grid/treeGrid. I use it when I have two entities in the same treeGrid :

    function hideFilters(filterColumnKeys) {
        $(".ui-iggrid-filterrow td").each(function () {
            for (j = 0; j < filterColumnKeys.length; j++) {
                var description = $(this).attr('aria-describedBy');
                if (description.indexOf(filterColumnKeys[j]) > 0) {
                    console.log("Hiding : " + description);
                    $(this).css('visibility', 'hidden');
                }
            }
        });
    };