Access data from a SFListview item when changing the value of a SFRating control

Hi! I have a SFListview controller on my page. For each item of the list, I have a SFRating control inside of it. I need to obtain a piece of data from the listview item, each time I change the value on the Rating control. Is that possible? Can you provide me an example? Thanks!

Andres.

8 Replies 1 reply marked as answer

SP Sakthivel Palaniyappan Syncfusion Team April 8, 2021 10:40 AM UTC

Hi Andres,

Greetings from Syncfusion.

We have analyzed your query and we have prepared sample based on this and please find the sample form below.

Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/RatingSample1650149062.zip

Please let us know if you have any other queries.

Regards,
Sakthivel P.
 



AA Andres Alvarado April 8, 2021 02:08 PM UTC

Hi Sakthivel for your response. I'll proceed to download the sample. Thanks for your help.

Andres.


SP Sakthivel Palaniyappan Syncfusion Team April 9, 2021 05:51 AM UTC

Hi Andres,

Thanks for the update. We will wait to hear from you.

Regards,
Sakthivel P.


AA Andres Alvarado April 12, 2021 02:25 PM UTC

Hi Sakthivel. I donwloaded the sample and I noticed that the rating value is obtained from the list. Thats not exactly what I had in mind. What I need is the following: 

Each item from the listview contains 5 different strings that I need to read everytime I clic on the rating control, not the list view, most probably using the  rating_ValueChanged event.

This is how I store the data for each item, on a observable collection: 

competencias.Add(new EvaluacionesCompetenciasEvaluadoViewModel
                        {
                            NUMROW = res.data.Table[i].NUMROW,
                            IDCOMPETENCIA = res.data.Table[i].IDCOMPETENCIA,
                            NOMBRECOMPETENCIA = res.data.Table[i].NOMBRECOMPETENCIA,
                            IDNIVELCOMP = res.data.Table[i].IDNIVELCOMP,
                            POREVALUAR = res.data.Table[i].POREVALUAR,
                            DESCSUPERIOR = res.data.Table[i].DESCSUPERIOR,
                            IDSUPERIOR = res.data.Table[i].IDSUPERIOR,
                            IDNIVEL = res.data.Table[i].IDNIVEL,
                            PESO = res.data.Table[i].PESO,
                            TIENEVALOR = res.data.Table[i].TIENEVALOR,
                            ESCALA = res.data.Table[i].ESCALA,
                            COMENTARIOS = res.data.Table[i].COMENTARIOS,
                            IDCUESTIONARIO = res.data.Table[i].IDCUESTIONARIO,
                            VALCONDUCTAS = res.data.Table[i].VALCONDUCTAS,
                            NIVEL = res.data.Table[i].NIVEL,
                            COLOR = "#"+ res.data.Table[i].COLOR,
                            VALORESCALA1 = res.data.Table[i].VALORESCALA1,
                            VALORESCALA2 = res.data.Table[i].VALORESCALA2,
                            VALORESCALA3 = res.data.Table[i].VALORESCALA3,
                            VALORESCALA4 = res.data.Table[i].VALORESCALA4,
                            VALORESCALA5 = res.data.Table[i].VALORESCALA5,
                            ESCALASMOSTRAR = res.data.Table[i].ESCALASMOSTRAR,
                            IconSource = "competencias.png",
                            ColorHexa = "#" + res.data.Table[i].COLOR,
                            Habilitado = false
                        });

On the rating control, if I choose the first item, I need to display the value stored in VALORESCALA1, if I choose the second item, I need to display the value on VALORESCALA2 and so on.

Thanks again for your help.

Andres.


AS Anandraj Selvam Syncfusion Team April 14, 2021 01:31 PM UTC

Hi Andres Alvarado, 
  
Currently we are validating the reported query and we will update the complete details on or before April 16, 2021. 
  
We appreciate your patience until then. 
  
Regards, 
Anand Raj S. 



AA Andres Alvarado April 15, 2021 04:00 PM UTC

Hi Anand, thanks for the update. Is there any way to add a string to the tooltip of the rating control? Thanks :D


AS Anandraj Selvam Syncfusion Team April 17, 2021 05:35 AM UTC

 Hi Andres Alvarado,

Query 1: On the rating control, if I choose the first item, I need to display the value stored in VALORESCALA1, if I choose the second item, I need to display the value on VALORESCALA2 and so on.

Still, we are validating the reported query and we will update the complete details on or before April 19, 2021.

We appreciate your patience until then.

Query 2: Is there any way to add a string to the tooltip of the rating control?

We would like to inform you that we don’t have support to add a modify the tooltip.

Regards,
Anand Raj S.
 



JK Jeya Kasipandi Syncfusion Team April 20, 2021 11:13 AM UTC

Hi Andres Alvarado,

Thanks for the patience.

Query : On the rating control, if I choose the first item, I need to display the value stored in VALORESCALA1, if I choose the second item, I need to display the value on VALORESCALA2 and so on.

We have validated your query and you can achieve your requirement either using rating value changed command or value changed event in Rating.

By using command, you can get the data for list view item in command parameter as like below code snippet

Xaml:
<rating:SfRating ItemCount="5" Grid.Row="1"  Value="{Binding RatingValue}">
                        <rating:SfRating.Behaviors>
                            <behaviors:EventToCommandBehavior Command="{Binding ValueChangedCommand}"  CommandParameter="{Binding .}"  EventName="ValueChanged"/>
                        </rating:SfRating.Behaviors>
                    </rating:SfRating>

In model:
   public void ValueChanged(object obj)
        {
            var bookName = (obj as BookInfo).BookName;
        }

By using Value Changed event, you can get the list view data as like below code snippet

Xaml:
<rating:SfRating ItemCount="5" Grid.Row="1" ValueChanged="SfRating_ValueChanged" BindingContext="{x:Reference listView}" Value="{Binding RatingValue}"/>

 C#:
  private void SfRating_ValueChanged(object sender, Syncfusion.SfRating.XForms.ValueEventArgs e)
        {
         
          var dataSource = ((sender as SfRating).BindingContext as SfListView).ItemsSource;
       
        }

Created sample based on this and please find the sample from below link.

Sample link:

Please check with the above and let us know if you have any concern.

Regards,
Jeya K


Marked as answer
Loader.
Up arrow icon