Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
How to Get Selected Column Layout Row on Button Cllick
posted

Hi ,

I am working on XamGrid. I Implemented XamGrid and that Xamgrid have some column layout, In One Column inside column layout i have a button while i am clicking on Button i am not getting any record. 

Please Help Me!

Thank You

 <ig:XamGrid.Columns>
                                                                                                    <ig:ColumnLayout Key="ProductHiererchy" HeaderVisibility="false" >
                                                                                                        <ig:ColumnLayout.Columns>
                                                                                                            <ig:TextColumn Key="ProdcutName" HeaderText="Product Name">
                                                                                                                <ig:TextColumn.HeaderTemplate>
                                                                                                                    <DataTemplate>
                                                                                                                        <TextBlock Text="Product"/>
                                                                                                                    </DataTemplate>
                                                                                                                </ig:TextColumn.HeaderTemplate>
                                                                                                            </ig:TextColumn>
                                                                                                            <ig:ColumnLayout Key="OrderDetail">
                                                                                                                <ig:ColumnLayout.Columns>
                                                                                                                    <ig:TextColumn Key="Description">
                                                                                                                        <ig:TextColumn.HeaderTemplate>
                                                                                                                            <DataTemplate>
                                                                                                                                <TextBlock />
                                                                                                                            </DataTemplate>
                                                                                                                        </ig:TextColumn.HeaderTemplate>
                                                                                                                    </ig:TextColumn>
                                                                                                                    <ig:UnboundColumn Key="OrderDetails" IsFilterable="False" HorizontalContentAlignment="Center"  HeaderText="" Width="50">
                                                                                                                        <ig:UnboundColumn.ItemTemplate>
                                                                                                                            <DataTemplate>
                                                                                                                                <Button x:Name="orderCalemdar" Background="Transparent" BorderBrush="Transparent" Click="petCalendarIcon_Click" HorizontalAlignment="Right" Width="42">
                                                                                                                                    <Button.Content>
                                                                                                                                        <Image Name="CalendarICon" Source="pack://application:,,,/OrderBooking;component/Images/calendar-128.png" Height="30" Width="41"></Image>
                                                                                                                                    </Button.Content>
                                                                                                                                </Button>
                                                                                                                             
                                                                                                                            </DataTemplate>
                                                                                                                        </ig:UnboundColumn.ItemTemplate>
                                                                                                                    </ig:UnboundColumn>

                                                                                                                </ig:ColumnLayout.Columns>
                                                                                                            </ig:ColumnLayout>
                                                                                                        </ig:ColumnLayout.Columns>
                                                                                                    </ig:ColumnLayout>
                                                                                                </ig:XamGrid.Columns>
                                                                                            </ig:XamGrid>

Parents
No Data
Reply
  • 34430
    Offline posted

    Hello Raj,

    I have been investigating into the behavior you are describing, and from your description it sounds like you are looking to either get the underlying data item to the Button that you are clicking, or you are looking to get the actual Row object that it is contained in. In either case, you can obtain these.

    In order to get the underlying data item, I would recommend casting the sender of your Button.Click event to the Button that raised that event. The DataContext of this Button will be an UnboundColumnDataContext object, which you can then use the RowData property of to get your underlying data item to the row that the Button is contained in. The code for this would look like the following:

            Button button = sender as Button;
            UnboundColumnDataContext context = button.DataContext as UnboundColumnDataContext;
    
            if(context != null)
            {
                var x = context.RowData; // <== Data Item                
            }

    To get the actual Row object, I would recommend utilizing the Infragistics.Windows.Utilities class and its static GetAncestorFromType method to get an ancestral CellControl element to the Button. This CellControl element has a Cell property, which has a Row property that you can use to get the actual underlying Row element. The code for this would look like the following:

                CellControl cell = Infragistics.Windows.Utilities.GetAncestorFromType(button, typeof(CellControl), false) as CellControl;
                if(cell != null)
                {
                    Row row = cell.Cell.Row as Row; // <== Actual Row 
                }

    I have attached a sample project to demonstrate the above. I hope this helps.

    Please let me know if you have any other questions or concerns on this matter.

    XamGridHierarchyGetRecordCase.zip

Children
No Data