This is a migrated thread and some comments may be shown as answers.

hide the column based on viewdata

4 Answers 435 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohammed
Top achievements
Rank 1
Mohammed asked on 04 Feb 2020, 06:44 AM

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 

 

4 Answers, 1 is accepted

Sort by
0
Mohammed
Top achievements
Rank 1
answered on 05 Feb 2020, 03:17 AM
any help please 
0
Tsvetomir
Telerik team
answered on 06 Feb 2020, 02:19 PM

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.
0
Mohammed
Top achievements
Rank 1
answered on 10 Feb 2020, 10:04 AM

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 

 

 

 

 
0
Tsvetomir
Telerik team
answered on 12 Feb 2020, 12:35 PM

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.
Tags
Grid
Asked by
Mohammed
Top achievements
Rank 1
Answers by
Mohammed
Top achievements
Rank 1
Tsvetomir
Telerik team
Share this question
or