AllInWorld99 provides a reference manual covering many aspects of web programming, including technologies such as HTML, XHTML, CSS, XML, JavaScript, PHP, ASP, SQL,FLASH, jQuery, java, for loop, switch case, if, if else, for...of, for...in, for...each,while loop, blogger tips, blogger meta tag generator, blogger tricks, blogger pagination, client side script, html code editor, javascript editor with instant output, css editor, online html editor, materialize css tutorial, materialize css dropdown list,break, continue statement, label,array, json, get day and month dropdown list using c# code, CSS button,protect cd or pendrive from virus, cordova, android example, html and css to make android app, html code play,telerik show hide column, Transparent image convertor, copy to clipboard using javascript without using any swf file, simple animation using css, SQL etc. AllInWorld99 presents thousands of code examples (accompanied with source code) which can be copied/downloaded independantly. By using the online editor provided,readers can edit the examples and execute the code experimentally.


Show Hide Column filed in telerik control:-
   We can hide or show the column filed in telerik grid, using the unique identify name. First need to find the asp grid and master table view and finally hide the column using hidecolumn property.


Example for hiding Column in Telerik Rad Grid:-
function hide()
{
        var radGrid = $find('<%= GridID_name.ClientID %>');
        var table = radGrid.get_masterTableView();
        var column = table.getColumnByUniqueName("Column_Unique_ID_here");
        table.hideColumn(column.get_element().cellIndex);
}


Example for showing Column in Telerik Rad Grid:-

function show()
{
        var radGrid = $find('<%= GridID_name.ClientID %>');
        var table = radGrid.get_masterTableView();
        var column = table.getColumnByUniqueName("Column_Unique_ID_here");
        table.showColumn(column.get_element().cellIndex);
}



Example Program:-

<script type="text/javascript">
 function show()
{
        var radGrid = $find('<%= GridID_name.ClientID %>');
        var table = radGrid.get_masterTableView();
        var column = table.getColumnByUniqueName("column2");
        table.showColumn(column.get_element().cellIndex);
}


 function hide()
{
        var radGrid = $find('<%= GridID_name.ClientID %>');
        var table = radGrid.get_masterTableView();
        var column = table.getColumnByUniqueName("column2");
        table.hideColumn(column.get_element().cellIndex);
}


 function fun_OnRowDataBound(sender,args)
{
  if(args.get_dataItem()["Location"] == 'null')
 {
   show();
 }
 else
 {
   hide();
 }
}

</script>

--------
--------
--------
<telerik:RadGrid ID="Telerik_Grid"  runat="server" Width="100%" AllowSorting="false" >
                                    <MasterTableView EnableNoRecordsTemplate="true">
                                        <NoRecordsTemplate>
                                            <div>
                                                There are no records to display</div>
                                        </NoRecordsTemplate>
                                        <Columns>
       <telerik:GridBoundColumn HeaderText="Name" DataField="Name" AllowSorting="false" UniqueName="column1">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn HeaderText="DOB" DataField="DOB"  AllowSorting="false" UniqueName="column2">
        </telerik:GridBoundColumn>
       <telerik:GridBoundColumn HeaderText="Place" DataField="Location" AllowSorting="false" UniqueName="column2">
        </telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings>
  <ClientEvents OnCommand="fun_OnCommand" OnRowDataBound="fun_OnRowDataBound" />
 </ClientSettings>
 </telerik:RadGrid>




Output:-

telerik show hide column


Advertisement


1 comment:

Total Pageviews