I am using VS 2010,Blend 4, Rad gridview version:2011.1.516.40, I have a rad gridview with multiple checkboxes and the header of the check box coloumn is toggle button, toggle button does select all check box and unselect all check box. My question is i want to save the tube type and corresponding check items with the header toggle button content name:
ex: sample tube 2 , Is Checked =true, header name = Standard-4
sample tube 3 , Is Checked =true, header name = Standard-1
Bascially i want to save for the given sample what are the header names selected. How can i do it using RAD Grid view
FYI please see the attached image to have a better idea.
Thanks
Sarag.
7 Answers, 1 is accepted
May you try to reattached the image you mentioned ? Thus we will get better comprehension of your specific requirements.
Regards,Maya
the Telerik team

I saw the image you attached in the other thread you started on the same topic. However, in order to keep our communication as consistent as possible, it would be great if we could continue it here.
Considering you specific requirement, I may suggest you to expose separate boolean properties in your business object, each of them bound to the corresponding column. Thus once you want to verify which are the checked check boxes for each item, you will have just run through its properties and get those that have a "True" value. Generally, it is always recommended to work with data items, instead of visual elements.
Maya
the Telerik team

I tried your suggestion, it doesnt work my from end, i am little bit confused, suppose if i am having 100 coloumns , do i need to expose 100 properties in my business object, can you send me a sample project with 20 rows and 10 coloumn with check boxes
public class CreateWorklist
{
public List<
WorklistAssociatedAssays
> SelectedAssays { get; set; }
}
public class WorklistAssociatedAssays
{
private string _associatedAssays;
private bool _isSelected;
public string AssociatedAssays
{
get { return _associatedAssays; }
set { _associatedAssays = value; }
}
public bool IsSelected
{
get { return _isSelected; }
set
{
_isSelected = value;
OnPropertyChanged(()=>IsSelected);
}
}
#region Implementation of INotifyPropertyChanged
protected void OnPropertyChanged<
T
>(Expression<
Func
<T>> action)
{
var propertyName = GetPropertyName(action);
OnPropertyChanged(propertyName);
}
private static string GetPropertyName<
T
>(Expression<
Func
<T>> action)
{
var expression = (MemberExpression)action.Body;
var propertyName = expression.Member.Name;
return propertyName;
}
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
Indeed, the recommended approach is to expose property for each of the columns as thus you will be sure that the values you get are for the corresponding item. Generally, what happens is that the visual elements - cells, check boxes, etc. - are reloaded and if not being bound to a property, a particular CheckBox might get checked for an item that does not have a checked value for this column.
Still, I am sending you a sample project illustrating how you may achieve such a result.
Maya
the Telerik team

The sample project does not work with my requirement, the check box columns are generated dynamically at runtime, so i dont have any idea of the count, in the previous screen user will select the number of check box columns, based on the count i need to generate the columns., please suggest me what is the good approach for this.
thanks
sarag.
The recommended approach would be always to work directly with the data items and their corresponding properties.So, I would definitely suggest you to expose appropriate properties for the columns and check their values - whether they are true or false. As mentioned previously due to the virtualization, you cannot count that retrieving the values of a visual elements will return the correct results. A possible solution would be to turn of the virtualization and work with the content of those elements. However, this may lead to some performance problems in case you handle a lot of data.
You may take a look at this blog post for a possible approach in scenarios similar to yours.
Maya
the Telerik team