Hello folks,
I Have problem like these ..In rad-grid ..i Have 20 Column above ....I am Put The allow scroll bar is true ..rad grid increased ..too wide
I want to give option to user when ever The User click on "Column " Link Button I want to hide That Column ..showing remaining column as
it is..But here I got some problem ..I am not aware of how to use column index based on "Click on Column ". These code I am used to get Column
Index but unfortunately ..I am not getting the Value ..
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "hideCol") { // Add the column index to hide to the hiddenColumnIndexes list hiddenColumnIndexes.Add(e.Item.ItemIndex); SetupShowHideColumns(); } }e.Item.ItemIndex ,I am Getting "-1" value Can help here to Getting The correct Column Index ..Form user click on Column ....The Following Picture Shows .."-" Symbol in Column Text Prefix ..so When user Click On "-" Button ..We Need to Hide that Column ..but here "I am not Know How get Column Index" raised By Event Column .
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) { // For the header row add a link button to each header // cell which can execute a row command if (e.Item.ItemType==GridItemType.Header) { // Loop through each cell of the header row for (int columnIndex = 0; columnIndex < e.Item.Cells.Count; columnIndex++) { LinkButton hideLink = new LinkButton(); hideLink.CommandName = "hideCol"; hideLink.CommandArgument = columnIndex.ToString(); hideLink.Text = "-"; hideLink.CssClass = "gvHideColLink"; hideLink.Attributes.Add("title", "Hide Column"); // Add the "Hide Column" LinkButton to the header cell e.Item.Cells[columnIndex].Controls.AddAt(0, hideLink); // If there is column header text then // add it back to the header cell as a label if (e.Item.Cells[columnIndex].Text.Length > 0) { Label columnTextLabel = new Label(); columnTextLabel.Text = e.Item.Cells[columnIndex].Text; e.Item.Cells[columnIndex].Controls.Add(columnTextLabel); } } } // Hide the column indexes which have been stored in hiddenColumnIndexes foreach (int columnIndex in hiddenColumnIndexes) if (columnIndex < e.Item.Cells.Count) e.Item.Cells[columnIndex].Visible = false; }The Below to Code to Bind the Data And Hide That Column Code .
Thanks
Reply me Any One.