4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 16 Dec 2008, 10:31 AM
Hi Pete,
I guess you are trying to select/unselect the Grouped items on clicking the GridGroupHeaderItem. If so you can try the following code snippet to achieve the required scenario.
ASPX:
CS:
JS:
Regards
Shinu
I guess you are trying to select/unselect the Grouped items on clicking the GridGroupHeaderItem. If so you can try the following code snippet to achieve the required scenario.
ASPX:
<input id="Hidden1" type="hidden" runat="server" /> |
CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridGroupHeaderItem) |
{ |
GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; |
string GroupIndx = item.GroupIndex; |
item.Attributes.Add("onClick", "SelectGroup('" + GroupIndx + "');"); |
} |
} |
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
if (Hidden1.Value!=string.Empty) |
{ |
foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) |
{ |
if (groupHeader.GroupIndex == Hidden1.Value) |
{ |
GridItem[] children = groupHeader.GetChildItems(); |
foreach (GridItem child in children) |
{ |
child.Selected = !child.Selected; |
} |
} |
} |
} |
} |
JS:
<script type="text/javascript"> |
function SelectGroup(GroupIndx) |
{ |
var input=document.getElementById('Hidden1'); |
input.value=GroupIndx; |
__doPostBack('RadGrid1.ClientID') |
} |
</script> |
Regards
Shinu
0
Pete
Top achievements
Rank 1
answered on 17 Dec 2008, 07:39 AM
Hi,
No, I want to select a group row itself so that it is possible to select either data row or group row from the grid.
Regards,
Pete
No, I want to select a group row itself so that it is possible to select either data row or group row from the grid.
Regards,
Pete
0
Shinu
Top achievements
Rank 2
answered on 17 Dec 2008, 10:02 AM
Hi Pete,
On suggestion will be to apply backcolor for the GridGroupHeader while clicking on it. Give a try with following code snippet and see if it helps.
CS:
Shinu
On suggestion will be to apply backcolor for the GridGroupHeader while clicking on it. Give a try with following code snippet and see if it helps.
CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridGroupHeaderItem) |
{ |
GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; |
item.Attributes.Add("onClick", "if(this.style.backgroundColor!='red'){this.style.backgroundColor='Red';}else{this.style.backgroundColor='Transparent';}"); |
} |
} |
Shinu
0
Pete
Top achievements
Rank 1
answered on 17 Dec 2008, 11:58 AM
Hi,
I think that I didn't explain clear enough what I try to do.
So I have RadGrid placed inside the RadComboBox and when the user selects a data row from the grid then the selected grid row's text/value is set as combobox selected text/value using the following code.
Now I want to do this same when user clicks the group row.
Regards,
Pete
I think that I didn't explain clear enough what I try to do.
So I have RadGrid placed inside the RadComboBox and when the user selects a data row from the grid then the selected grid row's text/value is set as combobox selected text/value using the following code.
function onRowSelected(sender, args) |
{ |
var selectedText = args.getDataKeyValue("TypeName"); |
var selectedValue = args.getDataKeyValue("ID"); |
// get combobox |
var combo = $find("ctl00_cph_rcbTest"); |
if (selectedValue.length > 0) |
{ |
combo.trackChanges(); |
combo.set_text(selectedText); |
combo.get_items().getItem(0).set_text = selectedText; |
combo.get_items().getItem(0).set_value(selectedValue); |
combo.commitChanges(); |
combo.hideDropDown(); |
} |
} |
Now I want to do this same when user clicks the group row.
Regards,
Pete