hide the column based on viewdata

5 posts, 0 answers
  1. Mohammed
    Mohammed avatar
    15 posts
    Member since:
    Mar 2019

    Posted 04 Feb 2020 Link to this post

    kendo grid In asp.net core project 

    how to Hide column DateResult 

    i have 

    columns.ForeignKey(p => p.result, (System.Collections.IEnumerable)ViewData["Result"], "id", "Name").Title("Result");

    columns.bound(c =>c.DateResult) in my Grid 

    and there is three type of result ViewData(agree - disagree -Inprogress)

    If the user select disagree  I want to hide the DateResult 

    Note

    popup editor 

    thanks 

     
  2. Mohammed
    Mohammed avatar
    15 posts
    Member since:
    Mar 2019

    Posted 04 Feb 2020 Link to this post

    any help please 
  3. Tsvetomir
    Admin
    Tsvetomir avatar
    796 posts

    Posted 06 Feb 2020 Link to this post

    Hi Mohammed,

    The columns of the Kendo UI Grid expose an option called Visible. You could utilize it in order to either show or hide a column:

    columns.Bound(p => p.ProductName).Visible(bool); pass a boolean value  

    If the hiding of the column has to happen on the client-side, then, you should use the hideColumn method:

    https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/hidecolumn

     

    Regards,
    Tsvetomir
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
  4. Mohammed
    Mohammed avatar
    15 posts
    Member since:
    Mar 2019

    Posted 10 Feb 2020 in reply to Tsvetomir Link to this post

    columns.ForeignKey(p => p.result, (System.Collections.IEnumerable)ViewData["Result"], "id", "Name").Title("Result");
    columns.bound(c =>c.DateResult) in my Grid 
    and there is three type of result ViewData(agree - disagree -Inprogress)
    If the user select disagree  I want to hide the DateResult 

    i want it as conditionally 

    if (result==disagree)

    {

    hide the DateResult

    }

    else{}

    it's possible or not please 

     

     

     

     
  5. Tsvetomir
    Admin
    Tsvetomir avatar
    796 posts

    Posted 12 Feb 2020 Link to this post

    Hi Mohammed,

    Since you would like to hide the column depending on the value from the DropDownList that is the foreign key, you should handle the "Change" event of the DropDownList. You should navigate to the ForeignKey.cshtml file and add it there.

    Within the handler, access the grid and hide the column with the method that I provided earlier. You could access the currently selected item from the DropDownList via the exposed event arguments:

    function onChange(e){
        var selectedItem = this.value();
    }

    I hope you find this helpful.

     

    Regards,
    Tsvetomir
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
Back to Top