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

[Solved] Check box problem

9 Answers 302 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sulagna
Top achievements
Rank 1
sulagna asked on 23 Nov 2010, 09:48 AM

Hi,
1.I have a gridview with 4 columns, one of which is a of gridviewcheckboxcolumn type. gridviewcheckboxcolumn is only one which can be edited. I have added these chekboxes at runtime. Now I'm trying  to check/uncheck cells in gridviewcheckboxcolumn but nothing happens. It seems like the cells are read only. What shoild i do to work it properly.I got to know that it doesnt work with SP2.

2.I also need to save the selected row but my check box value is not saved in DB.How can I save the entire row into DB

3.My check box is checked and read only when data exists in the DB else blank.What should I do?

Thanks
Sulagna

9 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 23 Nov 2010, 09:57 AM
Hello sulagna,

In order to provide you with an appropriate solution, I would need a bit more information about the exact scenario you want to accomplish and the corresponding grid settings. How exactly do you add the GridViewCheckBoxColumn ? Do you set any of its properties ?
Basically, you can save the data for the selected item by using the SelectedItem of the grid. In case you expose a boolean property for the CheckBox, there should be no problem for you to retrieve the data.
Considering the last question, I would also need more details about your exact requirements.
 

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sulagna
Top achievements
Rank 1
answered on 24 Nov 2010, 11:50 AM

 

 

 

Hi,Its a grid view checkbox column.here is my xaml but when page loads it becomes read only.I should be able to check uncheck the check boxes but i am not able to do.Please help.Mine is SP2.
<!--COlumn For Assign user Cheack Box-->

 

 

 

 

<telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsSelected,Mode=TwoWay}" EditTriggers="CurrentCellClick"

 

 

 

 

HeaderTextAlignment="Center"

 

 

 

 

IsSortable="True" IsResizable="False" AutoSelectOnEdit="True"

 

 

 

 

TextAlignment="Center">

 

 

 

 

<telerik:GridViewCheckBoxColumn.Header>

 

 

 

 

<TextBlock Text="Assign" VerticalAlignment="Center" TextWrapping="Wrap" />

 

 

 

 

</telerik:GridViewCheckBoxColumn.Header>

 

 

 

 

</telerik:GridViewCheckBoxColumn>

 

0
Maya
Telerik team
answered on 24 Nov 2010, 02:12 PM
Hi sulagna,

I have tested the scenario with the xaml code you sent, but I was not able to reproduce the issue you are referring to. I am attaching the sample project I used for replicating the problem.
Let me know in case of any discrepancies.

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sulagna
Top achievements
Rank 1
answered on 24 Nov 2010, 03:55 PM

I have a check box column in a RadGridView, and I can't seem to make it read only.What I want is a checkbox column that is NOT editable based on conditions.I want the checkboxes which are checked the entire row or that cell to be read only and other checkboxes which are unchecked to be editable.When my grid loads the page appears like my attached screen shot.The unchecked red circled checkboxes ahould be editable and checked one should be read only.

I set the individual column's ReadOnly property to True entire column is becoming read only..
I set the grid's AllowEditRow to False.
Nothing has any effect. Double clicking on checkbox makes it editable what do I have to do to make a simple read-only checkbox?
IsSelected is a boolean property I am binding to make it checked.

 

 

 

 

<telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsSelected}" AutoSelectOnEdit="False"

 

 

 

 

HeaderTextAlignment="Center"

 

 

 

 

IsSortable="True" IsResizable="False" > 

 

 

 

 

<telerik:GridViewCheckBoxColumn.Header> 

 

 

 

 

<TextBlock Text="Assign" VerticalAlignment="Center" TextWrapping="Wrap" />

 

 

 

 

</telerik:GridViewCheckBoxColumn.Header> 

 

 

 

 

</telerik:GridViewCheckBoxColumn>

 

 

 

 

My code:
private void CalculateRanges(ObservableCollection<Discipline> disciplineList, ObservableCollection<Discipline> projectDisciplineList)
        {
            foreach (Discipline discipline in disciplineList)
            {
                foreach (Discipline projDisciplineObj in projectDisciplineList)
                {
                    if (discipline.DisciplineId == projDisciplineObj.DisciplineId)
                    {
                        discipline.IsSelected = true;
                    }                   
                }
            }
        }

 

0
Maya
Telerik team
answered on 24 Nov 2010, 05:25 PM
Hello sulagna,

You may try to use the IsReadOnlyBinding property of the grid as demonstrated in this help article

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sulagna
Top achievements
Rank 1
answered on 26 Nov 2010, 03:13 PM

Hi,

The problem is how can I escape from the edit mode? For eg when I select a checkbox the checkbox gets edited with a tick then I come to the next row the editor gets removed from 1st row and when I select the next checkbox the editor comes.How can I escape from that? Because when I click save button only the 1st row gets saved if the editor doesn't get removed. If I select something else then the editor goes and 2 records gets saved.

In grid.jpg the red circle is the editor and if I click on save button only 1st record gets saved because the editor is still there.

In error.jpj 1st 2 records got saved because the editor is not there.

So in 1st case is there any way to tick the checkbox and directly save the records without removing the editor.

I am attaching 2 files for ur reference

Thanks
Sulagna



0
Maya
Telerik team
answered on 29 Nov 2010, 04:04 PM
Hi sulagna,

May you try to define your CheckBox column as follows:

<telerik:GridViewDataColumn IsReadOnly="True">                                  
        <
telerik:GridViewDataColumn.CellTemplate >
             <DataTemplate>
   <CheckBox IsChecked="{Binding MyProperty}"/>
             </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

In this way the column will not get into edit mode, but still you will be able to check/uncheck the CheckBox.
Let me know if it corresponds to your requirements.

Sincerely yours,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sulagna
Top achievements
Rank 1
answered on 30 Nov 2010, 12:10 PM

Hi,
<telerik:GridViewCheckBoxColumn >
                    <telerik:GridViewCheckBoxColumn.CellTemplate>
                        <DataTemplate>

                            <CheckBox  Checked="CheckBox_Checked" IsChecked="{Binding IsSelected}">                                                         </CheckBox>
                        </DataTemplate>
                    </telerik:GridViewCheckBoxColumn.CellTemplate>
                    <telerik:GridViewCheckBoxColumn.Header>
                        <TextBlock Text="Assign" VerticalAlignment="Center" TextWrapping="Wrap" />
                    </telerik:GridViewCheckBoxColumn.Header>
                </telerik:GridViewCheckBoxColumn>


I added this code and wrote this in .cs but its not firing the event.  
public void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            GridViewCheckBox cb = e.OriginalSource as GridViewCheckBox;
            if (cb.IsChecked == true)
            {
                Discipline editedDiscipline = e.OriginalSource as Discipline;
                EditedDisciplineList.Add(editedDiscipline);
            }
        }
My problem is I have a global list property i.e. EditedDisciplineList and it should contain only the selected check box rows.Now its taking the selected items only by firing RowEditEnded event.

But how can I do that without firing RowEditEnded event because when I check the checkbox editor(red circled one in jpeg) comes I dont want that.If I remove RowEditEnded event, EditedDisciplineList comes null inside save button.How to get the global list value in save button click event. If this problem will be fixed that checkbox issue will go.Because having RowEditEnded I hav to click save button twice to save data because of that editor issue.
public void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            ObservableCollection<Discipline> _updatedDisciplineList = EditedDisciplineList;              

            Project project = this.iClientStateService.SelectedProject;          
            if (_updatedDisciplineList != null && _updatedDisciplineList.Count > 0)    
            {
                ProcessDisciplineService.AddProjectDisciplines(_updatedDisciplineList, project, SaveProjectDisciplinesCallBack);
            }           
        }
public void RadProcessDisciplineView_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
        {
            if (e.EditOperationType == GridViewEditOperationType.Edit)
            {
                GridViewCheckBox cb = e.Row.Cells[0].Content as GridViewCheckBox;
                if (cb.IsChecked == true)
                {
                    Discipline editedDiscipline = e.NewData as Discipline;
                    EditedDisciplineList.Add(editedDiscipline);
                }
            }
        }

Regards,
Sulagna

0
Maya
Telerik team
answered on 02 Dec 2010, 09:30 AM
Hi sulagna,

As far as I could understand your requirements, you want to be able to check and uncheck the boxes in the GridViewCheckBoxColumn. Afterwards, once you click on your Save-button, you want to save only those items whose CheckBox is checked. 
So, if I am correct, you may handle the Click event of the Save-button, walk trough the Items collection of the RadGridView, get only those whose property - IsSelected I believe and save them. 
On the other hand, if you use the CheckBox only of seeing if the item has been selected or not, why don't you try to use the GridViewSelectColumn ?

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
GridView
Asked by
sulagna
Top achievements
Rank 1
Answers by
Maya
Telerik team
sulagna
Top achievements
Rank 1
Share this question
or