Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column Visibility from javascript is not working #193

Open
Deevan opened this issue Jul 20, 2019 · 2 comments
Open

Column Visibility from javascript is not working #193

Deevan opened this issue Jul 20, 2019 · 2 comments

Comments

@Deevan
Copy link

Deevan commented Jul 20, 2019

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
Copy link
Author

Deevan commented Jul 20, 2019

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
Copy link

Try this:

<script> function setGrid() { var jsonData = {}; jsonData['MyCol'] = true; MVCGrid.setColumnVisibility('MyGrid', jsonData); } $(document).ready(function () { setTimeout(setGrid, 0); }); </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants