joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
74 stars 55 forks source link

Column Visibility from javascript is not working #193

Open Deevan opened 5 years ago

Deevan commented 5 years ago

I have tried to set Column Visibility from client side. as directed HERE

On Line 78 On this code MVCGrid.setColumnVisibility('ColumnVisibilityGrid', jsonData); I am getting below error

Uncaught TypeError: **Cannot read property 'qsPrefix' of undefined**
    at Boolean.<anonymous> (script.js:282)
    at Function.each (jquery-2.2.3.min.js:2)
    at Object.setColumnVisibility (script.js:281)
    at HTMLDocument.<anonymous> (Receipt:73)
    at i (jquery-2.2.3.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-2.2.3.min.js:2)
    at Function.ready (jquery-2.2.3.min.js:2)
    at HTMLDocument.J (jquery-2.2.3.min.js:2)

According to above link I have set the column properties as

.WithAllowChangeVisibility(true)
.WithVisibility(false)

and tried .WithVisibility(false, true) and .WithVisibility(visible: false, allowChangeVisibility: true)

Any Help is highly appreciated..

Deevan commented 5 years ago

I found answer to this by my self.

This code MVCGrid.setColumnVisibility('ColumnVisibilityGrid', jsonData); is supposed to call on click event of a button.

I was trying to call it on document ready. because i wanted to set few columns to be visible automatically without asking user to choose columns.

I, also, tried to call jquery trigger click function on document ready but NO LUCK :( see my not working code below


@section scripts{
    <script type="text/javascript">
        $(function () {

                var jsonData = {};
                jsonData["Col_3"] = true;
                jsonData["Col_4"] = true;
                jsonData["Col_5"] = true;
                MVCGrid.setColumnVisibility('MyGrid', jsonData);

        });
    </script>
}

There has to be a way to call this functionality on page load/ document.ready

ANY SUGGESTIONS??

mcbeth111 commented 2 years ago

Try this: