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

GridView row events

4 Answers 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Haythem
Top achievements
Rank 1
Haythem asked on 09 Sep 2013, 08:12 AM
Hi!
i have a problem to work with gridViewRow events inside Polling duplex events. i explain :
i have a WCF service (Polling duplew service) that am using this way ;
i have a method GetActionDetailsDataAsync() that calls RecieveGetActionDetailsDataReceived() wich's been executed every 1 second.
i have a RadGridView with a GridViewRowDetail containing another RadGridView here is my code :

<telerik:RadGridView  ScrollViewer.HorizontalScrollBarVisibility="Disabled" Name="RadGridViewActionDetails" ItemsSource="{Binding Path=MyItemSourceList, Mode=OneWay}"  AutoGenerateColumns="False" LoadingRowDetails="Grid_LoadingRowDetails" >
            <telerik:RadGridView.Columns>
             
<telerik:GridViewToggleRowDetailsColumn />
<telerik:GridViewDataColumn Header="{Binding BindsDirectlyToSource=True}" Width="*" DataMemberBinding="{Binding VolumeOpen}"  HeaderTextAlignment="Center"  TextAlignment="Center"    />
<telerik:GridViewDataColumn Header="{Binding BindsDirectlyToSource=True}" Width="*" DataMemberBinding="{Binding LotsOpen}"  HeaderTextAlignment="Center"  TextAlignment="Center"    />
                 
</telerik:RadGridView.Columns>
 
            <telerik:RadGridView.RowDetailsTemplate >
                <DataTemplate>
                    <telerik:RadExpander IsExpanded="True">
                        <telerik:RadGridView x:Name="RadClosedPosition"   IsFilteringAllowed="False" Padding="50" FontSize="12" AutoGenerateColumns="False"
                                             d:DataContext="{d:DesignInstance model:ClosedDataPositionDTO}">
                            <telerik:RadGridView.Columns>
                              
                                <telerik:GridViewDataColumn Header="{Binding BindsDirectlyToSource=True}"  Width="*" DataMemberBinding="{Binding Volume}"  HeaderTextAlignment="Center"  TextAlignment="Center"  />
                                <telerik:GridViewDataColumn Header="{Binding BindsDirectlyToSource=True}"  Width="*" DataMemberBinding="{Binding Lot}"  HeaderTextAlignment="Center"  TextAlignment="Center"  />
 
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
                    </telerik:RadExpander>
                </DataTemplate>
 
            </telerik:RadGridView.RowDetailsTemplate>
</telerik:RadGridView>
for that grid i am using 3 events : RowLoaded,RowUloaded and LoadingRowDetails .
the main grid contains Open Position items and "IF" the row contains closed position the subGrid is displayed by clicking the toggle button in the first column of the main grid ... IF not the toggle button would not appear.
Before Polling Duplex it worked with the 3 events i used , my problem now is that i can't call the events inside the DoWorkRecieved method wich is executed every second ( the contain of the grid can be changed during execution)
Here is what i tried to do so far : 
private void Grid_LoadingRowDetails(object sender, GridViewRowDetailsEventArgs e)
        {
        if the open position contains one or many closed positions than
             radClosePosition.ItemsSource = item.ListClose;
             
        }
        private void Grid_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            //if the open position does not contain closed position than the row content is set to null
 
            var gridItem = e.Row.Item as ActionDetailsDto;
            if (gridItem != null)
                TmpSymbol = gridItem.SymbolOpen;
            //Debug.Assert(gridItem != null, "gridItem != null");
            if (gridItem != null && (e.Row.Item != null && gridItem.ListClose.Count == 0))
            {
                var row = e.Row.ChildrenOfType<GridViewCell>().First();
                row.Content = null;
            }
        }  
        private void Grid_RowUnloaded(object sender, RowUnloadedEventArgs e)
        {
        //if the open position does not contain closed position than the togglebutton  is hidden
            if (e.Row.Item != null)
            {
                var rowitem = e.Row.ChildrenOfType<GridViewCell>().First();
                rowitem.Visibility = Visibility.Visible;
            }
        }
and here is my main page code:
public MainPage()
        {
            InitializeComponent();
            /*..............................*/
                 _proxy.GetActionDetailsDataAsync("t.kheribi", "testAccount");
            _proxy.RecieveGetActionDetailsDataReceived += _proxy_RecieveGetActionDetailsDataReceived;
        }
 
void _proxy_RecieveGetActionDetailsDataReceived(object sender, FeedService.RecieveGetActionDetailsDataReceivedEventArgs e)
        {
            var serviceResultList = ParsingServiceTools.ParsingActionDetails(e.request.Arg);
            var deletedItemsList = new ObservableCollection<ActionDetailsDto>();
//this method is being executed each second and it would be perfect if i could handle here the GridViewEvents
             
 
             
        }
What i tried so far is to put  inside the recievRecieved method
RadGridViewActionDetails.RowLoaded += (Grid_RowLoaded);
RadGridViewActionDetails.RowUnloaded += (Grid_RowUnloaded);

but it didn't worked ; during executions if a closed position is added to the grid the toggle button remain hidden...
can you help me please to figure out a solution for this .

Waiting forward for your quick response 
KAROUI Haythem
IT Manager at Crea-Digital


4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 09 Sep 2013, 09:07 AM
Hello KAROUI,

Since the virtualization of RadGridView is turned on by default, it is not recommended to work with the visual elements (i.e. GridViewRow) and their properties. You would better work with the underlined data items. Please refer to our online documentation for a reference. 

In order to achieve your goal I can suggest you to use RowStyleSelector. Please follow the instructions on how to apply it from this help article.  You can also check our online demo

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Haythem
Top achievements
Rank 1
answered on 09 Sep 2013, 01:10 PM
Hi again,
It doesn't work cuz i need to hide just the button icon not the hole row...
Let me give you that image present.png
First of all, that grid, is containing real time data;
Each row represents an OpenPosition object,
If the row (open position) is associated with a close position than => the button "+" in the toggle button column will appear. and disappear in the opposite case...
Until now i have realized that with the 3 events : LoadingRowDetails, RowLoaded and RowUloaded.
My problem now is about how to handle these events with real time changing data...
E.g. : I wanted to handle these events inside the recieved method of the service...

Cordially,
Haythem Karoui
0
Accepted
Dimitrina
Telerik team
answered on 09 Sep 2013, 03:06 PM
Hi,

Those events will be raised only when the specific actions (loading row details, loading a row, unloading a row) happens. If you want to change the state of the toggle button depending on a real changing data, then I would suggest you to try using a RowStylector and conditionally decide (based on your data) what Row Style to return. You will need to also redefine the template of the GridViewRow to hide the toggle button for some rows.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Haythem
Top achievements
Rank 1
answered on 09 Sep 2013, 03:32 PM
hi,
i tried cell style selector and it worked... thank you very much for your effectual assistance.

Best Regards,
KAROUI Haythem
IT Manager at Crea-Digital
effectual
Tags
GridView
Asked by
Haythem
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Haythem
Top achievements
Rank 1
Share this question
or