Specific row detail(ColumnLayout) expansion in code behind

Not Answered This post has 0 verified answers | 43 Replies | 3 Followers Thread's RSS feed.

pragati_sd
Points 665
Replied On: Wed, May 9 2012 9:34 AM Reply

Hello,

My requirement is lazy binding of the column layout. On click of any cell of a row or on click of the expansion indicator of row, I want to load the data for columnlayout in code behind and keep that row in expanded state.
With the events - 

        void dataGrid_CellClicked(object sender, Infragistics.Silverlight.CellClickedEventArgs e)
        {
            IsCellClicked = true;
            ActiveRow = (Row)e.Cell.Row;
            lstCurrentData = (List<ChildNode>)dataGrid.ItemsSource;

            string strSelectedID = ((ChildNode)e.Cell.Row.Data).ID;
            List<ChildNode> lstChildren = new List<ChildNode>();
            lstChildren = GetTheDataByParentID(strSelectedID);
  
     /* To get the children assign to respective node */
            SearchRecursive(lstCurrentData, strSelectedID, lstChildren);

            dataGrid.ItemsSource = null;
            dataGrid.ItemsSource = lstCurrentData;
            dataGrid.UpdateLayout();
        }

and

         void dataGrid_RowExpansionChanged(object sender, Infragistics.Silverlight.RowExpansionChangedEventArgs e)
         {
             List<ChildNode> vm = dataGrid.DataContext as List<ChildNode>;
             lstCurrentData = (List<ChildNode>)dataGrid.ItemsSource;
 
             string strSelectedID = ((ChildNode)e.Row.Data).ID;
             List<ChildNode> lstChildren = new List<ChildNode>();
             lstChildren = GetTheDataByParentID(strSelectedID);
 
             SearchRecursive(lstCurrentData, strSelectedID, lstChildren);
 
             dataGrid.ItemsSource = null;
             dataGrid.ItemsSource = lstCurrentData;
            dataGrid.UpdateLayout();
         }

I get the data in ColumnLayout, but I need the respective row in expanded state. Now as the code in RowExpanded event is reassigning the ItemSource, its not allowing the row to expand on expander arrow click. But as I want to load the data for column layout at the time of expand, I've to do it in that event itself. Is there any other way for this? Please, help.

Thanks,
Pragati.

 

 

 

 

  • Post Points: 20

All Replies

[Infragistics]Stefan
Points 81,598
Replied On: Thu, May 10 2012 10:22 AM Reply

Hello Pragati,

 

Thank you for your post. I have been looking into it and it seems like that this is the best way of achieving the thing you want. If I think of a batter way, I will let you know.

Sincerely,
Stefan, MCPD
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
pragati_sd
Points 665
Replied On: Fri, May 11 2012 6:13 AM Reply

Hello Stefan,
I'm using the dll Infragistics.Silverlight.XamWebGrid.v9.2, VS 10, SL4. My data is of multiple depth heirarchy.
As I need lazy binding, I tried it orher way. I get the another XamWebGrid in ColumnLayout through TemplateColumn - DataTemplate. To get the cell click event of this grid added in xaml's resources -
<UserControl.Resources>
        <DataTemplate x:Name="MyDataTemplate">
            <Grid>
                <igGrid:XamWebGrid CellClicked="dataGrid_CellClicked"  ItemsSource="{Binding Children}"/>
            </Grid>
        </DataTemplate>
</UserControl.Resources>

In code behind -

        void dataGrid_RowExpansionChanging(object sender, Infragistics.Silverlight.CancellableRowExpansionChangedEventArgs e)
        {
            if (IsRowAlreadyExpanded == false && e.Row.IsExpanded == false)
            {
                ActiveRow = (Row)e.Row;
                dataGrid_CellClicked(sender, new Infragistics.Silverlight.CellClickedEventArgs());
            }
        }
        void dataGrid_CellClicked(object sender, Infragistics.Silverlight.CellClickedEventArgs e)
 {
     if (ActiveRow == null)
  ActiveRow = (Row)e.Cell.Row;
     CustomerNode objnode = new CustomerNode();
     lstCurrentData = (List<ChildNode>)dataGrid.ItemsSource;

     strSelectedID = ((ChildNode)ActiveRow.Data).ID;
     List<ChildNode> lstChildren = new List<ChildNode>();
     /* To get the children of respective node */
     lstChildren = objnode.GetTheDataByParentID(strSelectedID, lstParentChildData);
     /* To search and assign the children to respective nodes for grid ItemSource */
     SearchRecursive(lstCurrentData, strSelectedID, lstChildren);
     if (lstChildren.Count > 0)
     {
  TemplateColumn objTempleteColoumn;
  objTempleteColoumn = new TemplateColumn()
  {
      Key = "Children",
      ItemTemplate = (DataTemplate)this.Resources["MyDataTemplate"]
  };
  try
  {
      e.Cell.Column.ColumnLayout.Columns.Add(objTempleteColoumn);
                    ////e.Cell.Row.ColumnLayout.Columns.Add(objTempleteColoumn);
  }
  catch (Exception)
  {
      throw;
  }
     }

     IsRowAlreadyExpanded = false;
     ActiveRow = null;
 }
 
With this, I get the children data bounded to the grid in template, but I'm not getting the heirarchical display. I get like -

Actually, the grid should be assigned as a child of first row, as I've clicked the cell in first row & data is updated respectively. Please, let me know the better way, how I can assign this Grid of children in columnlayout, if I'm having the same parent in multiple(non-clicked) rows. Additionaly, the basic requirement is I need the specific row & its upper heirarchy in expanded state.

Thanks,
Pragati.

 

  • Post Points: 20
[Infragistics]Stefan
Points 81,598
Replied On: Mon, May 14 2012 2:31 AM Reply

Hello Pragati,

I have created a sample project for you with the functionality you want. Basically I used TemplateColumnLayout where I used the DataTemplate you created. Please let me know if this helps you or you need further assistance on this matter.

Looking forward for your reply.

Sincerely,
Stefan, MCPD
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
pragati_sd
Points 665
Replied On: Mon, May 14 2012 5:01 AM Reply

Hello Stefan,
Thanks for your reply. As I've mentioned, I'm using the dll -  Infragistics.Silverlight.XamWebGrid.v9.2. So, may be because of that I'm not getting TemplateColumnLayout. Will you please check & confirm how I can get the functionality with Infragistics.Silverlight.XamWebGrid.v9.2? I need to use this dll specifically.

Thanks,
Pragati.

 

 

 

 

  • Post Points: 20
[Infragistics]Stefan
Points 81,598
Replied On: Mon, May 14 2012 7:40 AM Reply

Hello Pragati,

 

I have tested the sample I sent you with version 9.2 and there aren’t such elements that I used in 12.1 and it seems like that the functionality you want cannot be without them and since version 9.2 is retired one, we no longer provide fixes and implement features for it, so my suggestions is to download our latest one (12.1).

 

Hope this helps you.

Sincerely,
Stefan, MCPD
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
pragati_sd
Points 665
Replied On: Mon, May 14 2012 9:03 AM Reply

Hello Stefan,
Lets keep the version problem aside. My requirement is -
Expand the row on cell click or expander click & get the children data loaded at the same time. Now, with observable collection, I'm getting this done. But, I need the chidren data in Template-DataTemplate; becouse whenever I need to change the childrendata, I'll only change that specific grid's ItemSource property & leave that row expanded. Is this possible in code behind - To add the children data to IemSource property & it is in the row detail of specific row through code as I've tried to add with ColumnLayouts.

 

  • Post Points: 20
[Infragistics]Stefan
Points 81,598
Replied On: Tue, May 15 2012 3:43 AM Reply

Hello,

I have modified the sample I sent you before, so now the ItemsSource of the XamGrid in the Childbands is set when the Row is expanded.

Hope this helps you.

Sincerely,
Stefan, MCPD
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
pragati_sd
Points 665
Replied On: Tue, May 15 2012 4:29 AM Reply

Hello Stefan,
Thanks for your reply. But, how can I add the columnlayout(row detail) in code behind?

like -
TemplateColumnLayout obj = new TemplateColumnLayout();
.....ColumnLayouts.Add(TemplateColumnLayout);

Pragati

 

  • Post Points: 20
[Infragistics]Stefan
Points 81,598
Replied On: Wed, May 16 2012 1:44 AM Reply

Hello Pragati,

I have modified the sample further, so now the TempalteColumnLAyout is added in code behind, in the RowInitialized event.

Hope this helps you.

Sincerely,
Stefan, MCPD
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
pragati_sd
Points 665
Replied On: Wed, May 16 2012 10:11 AM Reply

Hello Stefan,
Thanks for your reply. The sample project helps me a lot. Now, it seems I'm just a step back to my goal. I need the grid in DataTemplate is to be also AutoGenerateColumns = false. I get this done with assiging the events of root grid to this grid as well. But, while row creation though I'm adding the ColumnLayout only for the nodes having children, the expander indicator & blank row details(ColumnLayout) showing for the nodes which are not having children at all.

Code flow is like -
1) Root data (Observable collection) get assigned to root grid. If any node is having chidren, expand indicator is shown, but all rows are collapsed.
2) On click of expander or on click of any cell of row, the respective row data updated with children & row gets expanded.
Here, if one of the children rows is having chidren in turn & other rows are not having any chidren at all; still all the rows are shown with expand indicator. They get expanded on click with blank template.
Attaching the sample project. For csv file, please set the Build Option as Resources in its Properties. I'm using VS10, SL4 and Infragistics dll 10.3

Thanks,
Pragati.
 

 

  • Post Points: 20
[Infragistics]Stefan
Points 81,598
Replied On: Thu, May 17 2012 6:56 AM Reply

Hello Pragati,

I have modified the sample I sent me, so now it has the functionality you want. There aren’t ExpansionIndicators if there is no ChildData.

Hope this helps you.

Sincerely,
Stefan, MCPD
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
pragati_sd
Points 665
Replied On: Thu, May 17 2012 8:12 AM Reply

Hello Stefan,

Thanks for your reply. I checked the project, but with dll 10.3. I'm not sure, if I'm getting this error because of this version. The XamlException I got in InitializeComponent() is -

{System.Windows.Markup.XamlParseException: Set property '' threw an exception. [Line: 15 Position: 49] ---> System.NotSupportedException: Cannot set read-only property ''.
   at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
   at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, XamlPropertyToken inProperty, XamlQualifiedObject& inValue)
   --- End of inner exception stack trace ---
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at XamGridExpand.ucLoadDataInTemplateColumnLayout.InitializeComponent()
   at XamGridExpand.ucLoadDataInTemplateColumnLayout..ctor()}

Will you plz chk the project again with dll 10.3 & confirm with me.

Thanks,
Pragati.

  • Post Points: 20
[Infragistics]Stefan
Points 81,598
Replied On: Fri, May 18 2012 2:44 AM Reply

Hello Pragati,

 

I have tested the sample with the RTM (1006) and the latest service release(2329) of 10.3 and everything seems to work ok on my side. I can suggest you download the latest service release of 10.3 by logging to our web site and going to My IG \My Keys and Downloads.

 

Looking forward for your reply.

Sincerely,
Stefan, MCPD
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 20
pragati_sd
Points 665
Replied On: Fri, May 18 2012 2:53 AM Reply

Hello Stefan,
The version I've is - 10.3.20103.1006.  Is it the same you tried with? Please, confirm back.

Thanks,
Pragati.


  • Post Points: 20
Page 1 of 3 (44 items) 1 2 3 Next > | RSS