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

Chang Current Row at chang current row at hierarchical

14 Answers 249 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sally Attalla
Top achievements
Rank 1
Sally Attalla asked on 23 Sep 2010, 01:44 PM
Hello,
               I want  to  chang  current  row  at  radgrid    .I  use  3 level  hierarchical  and  want  to  chang seleted  row  from     level  1  to  level 2  and  so on.


14 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 24 Sep 2010, 09:06 AM
Hello Sally,

Let me see if i understood your question, if you click on a row let's say from the root grid, you want to automatically select the first line from child 1, first line from the child of child 1 and so on?

Best regards,
Emanuel Varga
0
Sally Attalla
Top achievements
Rank 1
answered on 24 Sep 2010, 12:09 PM
Hellow  Emanuel,
                  Thanks  for  your  replay,
                 I want  by  code    I  set  Current Row    from  any  template  level  to  another  template.
i have:
  • root  1 
                  child 1-1
                                 child  1-1-1
                                 child  1-1-2
                  child 1-2
                                child 1-2-1
                                child 1-2-2

  • root  2
                    child 2-1
                                 child  2-1-1
                                 child  2-1-2
                  child 2-2
                                child 1-2-1
                                child 1-2-2

Ex:

when    current  row  = child  2-1-1
I  want  to  set  by  code  current row    say    child 2-2


when   current  row=root  2
I  want  to  set  by  code  current row    say       child 1-2-1
and  so  on................



0
Richard Slade
Top achievements
Rank 2
answered on 24 Sep 2010, 12:26 PM
Hi Sally, 

Still unsure of what you mean. Can you post a screenshot? 
Perhaps you want to take a row from the top level and place it in the child template? 

E.g. 
Header Row 1
Header Row 2 (move me to be a child of Header Row 3)
Header Row 3
     Child Row 1
     Child Row 2
Header Row 3

Richard
0
Sally Attalla
Top achievements
Rank 1
answered on 24 Sep 2010, 12:48 PM
Hi  Richard
 I  mean :
I  have  old  data  of   (at  gridOldData)     and    three  level  data  as  (Product   -Part  -SubPart)  (at  gridMasterDetails)
  and  when  enter  update  of  any    row (at  gridOldData )   I  want   set  current  row    to  (at  gridMasterDetails)    the   that  has  data  of  old  row
0
Emanuel Varga
Top achievements
Rank 1
answered on 24 Sep 2010, 02:21 PM
Hello again Sally,

Sorry, it's still pretty hard for me to understand because i don't see the connections you are talking about, it would be great if you could create a small test form with all the data and copy paste it here, if you can i will try to help you further...

Best regards,
Emanuel Varga
0
Sally Attalla
Top achievements
Rank 1
answered on 25 Sep 2010, 09:05 AM
Hello    Emanue
                            This  replay  have  3  images  to  clear   what  I  want .
at  image  root  this  is  current  row  .  I  want  ti  change  current    row  to  be  as   in  image  child     and  change  it  again  to  be  as   in  image  another  child.
Thanks  for  your  intrest.
0
Emanuel Varga
Top achievements
Rank 1
answered on 25 Sep 2010, 11:10 AM
Hello again Sally,

So you want the entire hierarchy selected?

Something like in the attached image?

Best Regards,
Emanuel Varga
0
Sally Attalla
Top achievements
Rank 1
answered on 25 Sep 2010, 12:56 PM
Hello Emanuel Varga ,
Thanks a lot for your replay and your interst
i want what you say but each case individual as :
when a row is selected in root level i want to  select anther row but in any child level and  opposite case when any row selected in child level i want to select row in root level
0
Alexander
Telerik team
answered on 28 Sep 2010, 05:20 PM
Hello Sally,

Let's define two different cases in your scenario:

1. A RadGridView row contained in the MasterTemplate is the current row and you need to change it to a row in the child template of the MasterTemplate's child template (second level child template). You can achieve this using:
GridViewTemplate template = this.radGridView1.CurrentRow.ViewTemplate;
 
if (template == this.radGridView1.MasterTemplate)
{
    this.radGridView1.CurrentRow = template.Templates[0].Templates[0].Rows[0];
}

2. A RadGridView row from the second level child template is the current row and you need to change it to a row in the first level child template. You can achieve this using:
GridViewTemplate template = this.radGridView1.CurrentRow.ViewTemplate;
 
if (template == this.radGridView1.MasterTemplate.Templates[0].Templates[0])
{
    this.radGridView1.CurrentRow = template.Parent.Rows[0];
}

I hope it helps.

Regards,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Emanuel Varga
Top achievements
Rank 1
answered on 28 Sep 2010, 08:29 PM
Hello Alexander,

I was thinking that he wants to do something else, and I've tried a few things, got close to a solution but not close enough, i was thinking that for an n level hierarchy, all the parents are selected (all the parent rows until the current child or including the current child if that child was selected), and from what i know you cannot achieve this trough current row

I was trying something with RowFormatting or CellFormatting to change the background color for the entire hierarchy until the actual CurrentRow, when the CurrentRowChanged, call an update action and handle the background color for rows there.

Best Regards,
Emanuel Varga
0
Sally Attalla
Top achievements
Rank 1
answered on 29 Sep 2010, 12:26 PM
Hello Alexander,
thanks a lot for your replay
the first part it is exactly what i need but the solution not work


GridViewTemplate template = this.dgridContractDetails.CurrentRow.ViewTemplate;
          if (template == this.dgridContractDetails.MasterGridViewTemplate)
          {
              dgridContractDetails.CurrentRow = template.ChildGridViewTemplates[0].ChildGridViewTemplates[0].Rows[2];
          }

but the second part . it is not what i need . My problem is when selected row in child level i want to change selected row to any row in root level not only its parent.
Best Regards,
Sally
0
Alexander
Telerik team
answered on 01 Oct 2010, 01:19 PM
Hello Sally,

The code snippets I gave are relevant to the last version of the RadGridView control - Q2 2010 SP2. Please tell us which version you use if you meet difficulties in using the snippets.

Using the second code snippet from my previous answer you can select any row from the Parent template:

GridViewTemplate currentTemplate = this.radGridView1.CurrentRow.ViewTemplate;
GridViewTemplate parentTemplate = currentTemplate.Parent;
 
// parentTemplate.Rows collection contains all rows from the upper level template

You can access any template and any row of the RadGridView control using recursive algorithm like:

GridViewTemplate parentTemplate = this.radGridView1.CurrentRow.ViewTemplate.Parent;
while (parentTemplate != null)
{
    // parentTemplate.Templates contains all templates from the next level
    // parentTemplate.Rows contains all rows from this template
 
    parentTemplate = parentTemplate.Parent;
}

Please tell us if this covers you scenario.

Best regards,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sally Attalla
Top achievements
Rank 1
answered on 09 Oct 2010, 01:18 PM
Hello Alexander,
thanks a lot for your replay.
I  used   RadGridView control - Q1 2010 SP1
0
Alexander
Telerik team
answered on 14 Oct 2010, 08:42 AM
Hello Sally,

Please let us know if upgrading to version Q2 2010 SP2 addresses the issue in your project and you can use the suggested approaches. Do not hesitate to write back if you have more questions.

Best regards,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Sally Attalla
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Sally Attalla
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Alexander
Telerik team
Share this question
or