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

[Solved] Grid Expand Click problem

7 Answers 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 26 Aug 2013, 10:53 AM
Team

I am having issue on grid exapand button click.

In my example I am hiding some buttons on Grid Item Data bound event. It works fiine all case but In case of Expand click it displaying all button on screen.

I don't want to display button on certain status

If "Success"
   The Button Hide
Else If "Pending"
   Display button

7 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Aug 2013, 11:14 AM
Hello,

Please use prerender event in-place of itemdatabound event.

protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
        {
            //Acceess parent Item
           // Access parent button here set  visibility
            if (item.HasChildItems)
            {
                foreach (GridDataItem citem in item.ChildItem.NestedTableViews[0].Items)
                {
                    //Access child item
                   // Access child button here set  visibility
                }
            }
        }
    }


Thanks,
Jayesh Goyani
0
Rahul
Top achievements
Rank 1
answered on 26 Aug 2013, 11:34 AM
Thanks for reply dear.


Acutally in my case I want to disable GridEditCommandColumn if status is "Success"

How to find GridEditCommandColumn on page pre render event ?
0
Princy
Top achievements
Rank 2
answered on 26 Aug 2013, 12:21 PM
Hi Rahul,
Please try the below code snippet to hide the GridEditCommandColumn.

C#:
protected void RadGrid1_PreRender2(object sender, EventArgs e)
      {
          foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
          {
             //Your Condition
              {
                  LinkButton linkParent = (LinkButton)item["GridEditCommandColumn1"].Controls[0];// Access the parent GridEditCommandColumn
                  linkParent .Visible = false;           
                  if (item.HasChildItems)
                  {
                      foreach (GridDataItem childitem in item.ChildItem.NestedTableViews[0].Items)
                      {
                          LinkButton linkChild= (LinkButton)childitem ["GridEditCommandColumn"].Controls[0];//Access the child GridEditCommandColumn
                          linkChild.Visible = false;                          
                      }
                  }
              }
          }
      }

Thanks,
Princy
0
Rahul
Top achievements
Rank 1
answered on 26 Aug 2013, 01:13 PM
Thanks Princy

It give me erorr in bleow statement Index out of range..

LinkButton linkParent = (LinkButton)item["GridEditCommandColumn1"].Controls[0];// Access the parent GridEditCommandColumn

My button on parrent .

Please help
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Aug 2013, 02:15 PM
Hello,

Please try with the below code snippet.

<telerik:RadGrid ID="RadGrid1" runat="server" OnPreRender="RadGrid1_PreRender">
        <MasterTableView>
            <Columns>
                <telerik:GridEditCommandColumn UniqueName="ParentEdit">
                </telerik:GridEditCommandColumn>
            </Columns>
            <DetailTables>
                <telerik:GridTableView>
                    <Columns>
                        <telerik:GridEditCommandColumn UniqueName="ChildEdit">
                        </telerik:GridEditCommandColumn>
                    </Columns>
                </telerik:GridTableView>
            </DetailTables>
        </MasterTableView>
    </telerik:RadGrid>
    </form>
foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
        {
            //Your Condition
            {
                LinkButton linkParent = (LinkButton)item["ParentEdit"].Controls[0];// Access the parent GridEditCommandColumn
                linkParent.Visible = false;
                if (item.HasChildItems)
                {
                    foreach (GridDataItem childitem in item.ChildItem.NestedTableViews[0].Items)
                    {
                        LinkButton linkChild = (LinkButton)childitem["ChildEdit"].Controls[0];//Access the child GridEditCommandColumn
                        linkChild.Visible = false;
                    }
                }
            }
        }


Thanks,
Jayesh Goyani
0
Rahul
Top achievements
Rank 1
answered on 27 Aug 2013, 07:49 AM
Still having same problem


LinkButton linkParent = (LinkButton)item["ParentEdit"].Controls[0];// Access the parent GridEditCommandColumn
linkParent.Visible = false;



Still giving me expception index out of range..

See in my application

I am hiding Edit COmmand Column link button when status is "Success" it works fine... But when i click on Expand/Collpase option ..It will automatically display  Edit button for all rows whos status is not Scucess. I don't want to dispaly Edit button.


Please help urgent. Edit Command Column in parent
0
Jayesh Goyani
Top achievements
Rank 2
answered on 27 Aug 2013, 09:27 AM
Hello,

Can you please provide your radgrid markup(aspx) code?

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Rahul
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or