Hi,
I am fairly new to telerik grid so please be patient. I have a nested grid which displays Brokers in the main grid and then Broker contacts within it in the nested grid. I want the nested grid to be able to add and update the contacts. I currently have the nested grid opening up a rad window when the user clicks on the 'Add New Broker'. I am using a CommandItemTemplate for this and calling a javascript function on the onclick event of it. I do something similar for the edit using a GridTemplateColumn and it works fine since I can get the values of the fields using DataBinder.Eval... Is there any way I can get the value of the id of the parent row (in this case BrokerOfficeID) to pass as a parameter of the function in the CommandItemTemplate? I have spent a few days trying to figure this out and I'm kinda stuck... Everything else seems to be working great! Thanks for any help!!!
here is the code for the grid/nested grid
Here are the javascript functions...
I am fairly new to telerik grid so please be patient. I have a nested grid which displays Brokers in the main grid and then Broker contacts within it in the nested grid. I want the nested grid to be able to add and update the contacts. I currently have the nested grid opening up a rad window when the user clicks on the 'Add New Broker'. I am using a CommandItemTemplate for this and calling a javascript function on the onclick event of it. I do something similar for the edit using a GridTemplateColumn and it works fine since I can get the values of the fields using DataBinder.Eval... Is there any way I can get the value of the id of the parent row (in this case BrokerOfficeID) to pass as a parameter of the function in the CommandItemTemplate? I have spent a few days trying to figure this out and I'm kinda stuck... Everything else seems to be working great! Thanks for any help!!!
here is the code for the grid/nested grid
<
telerik:RadGrid
ID
=
"grdBrokers"
runat
=
"server"
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
AllowPaging
=
"True"
OnNeedDataSource
=
"grdBrokers_NeedDataSource"
AllowFilteringByColumn
=
"True"
EnableLinqExpressions
=
"False"
OnDetailTableDataBind
=
"grdBrokers_DetailTableDataBind"
Skin
=
"Office2007"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
DataKeyNames
=
"BrokerOfficeID"
Height
=
"100%"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
Position
=
"Bottom"
/>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
HorizontalAlign
=
"Center"
/>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
HorizontalAlign
=
"Center"
/>
</
ExpandCollapseColumn
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"BrokerContactID"
Name
=
"BrokerContacts"
Width
=
"100%"
AllowFilteringByColumn
=
"false"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
SortExpression
=
"BrokerOfficeID"
HeaderText
=
"Office ID"
HeaderButtonType
=
"TextButton"
DataField
=
"BrokerOfficeID"
UniqueName
=
"BrokerOfficeID"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"BrokerContactID"
HeaderText
=
"Contact ID"
HeaderButtonType
=
"TextButton"
DataField
=
"BrokerContactID"
UniqueName
=
"BrokerContactID"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"Name"
HeaderText
=
"Contact Name"
HeaderButtonType
=
"TextButton"
DataField
=
"Name"
UniqueName
=
"Name"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"Email"
HeaderText
=
"Email"
HeaderButtonType
=
"TextButton"
DataField
=
"Email"
UniqueName
=
"Email"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
HeaderText
=
"Edit"
UniqueName
=
"TemplateEditColumn"
>
<
HeaderStyle
Width
=
"30px"
HorizontalAlign
=
"Center"
/>
<
ItemStyle
Width
=
"30px"
HorizontalAlign
=
"Center"
/>
<
ItemTemplate
>
<
a
href
=
"#"
onclick
=
"ShowEditBrokerContactForm('<%# DataBinder.Eval(Container.DataItem, "
BrokerOfficeID") %>','<%# DataBinder.Eval(Container.DataItem, "BrokerContactID") %>');"><
img
id
=
"Img1"
alt
=
""
src
=
"~/App_Themes/Images/edit.gif"
runat
=
"server"
border
=
"0"
/></
a
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
CommandItemTemplate
>
<
a
href
=
"#"
onclick="return ShowInsertBrokerContactForm('<%# get id of parent row here %>);">Add New Broker Contact</
a
>
</
CommandItemTemplate
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"ID"
DataField
=
"BrokerOfficeID"
FilterControlWidth
=
"30px"
SortExpression
=
"BrokerOfficeID"
UniqueName
=
"BrokerOfficeID"
HeaderButtonType
=
"TextButton"
>
<
HeaderStyle
Width
=
"30px"
/>
<
ItemStyle
Width
=
"30px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Broker Office"
DataField
=
"Name"
FilterControlWidth
=
"300px"
SortExpression
=
"Name"
UniqueName
=
"Name"
HeaderButtonType
=
"TextButton"
>
<
HeaderStyle
Width
=
"300px"
/>
<
ItemStyle
Width
=
"300px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Company Code"
DataField
=
"CompanyCode"
FilterControlWidth
=
"35px"
SortExpression
=
"CompanyCode"
UniqueName
=
"CompanyCode"
HeaderButtonType
=
"TextButton"
>
<
HeaderStyle
Width
=
"35px"
/>
<
ItemStyle
Width
=
"35px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
HeaderText
=
"Edit"
UniqueName
=
"TemplateEditColumn"
>
<
HeaderStyle
Width
=
"30px"
HorizontalAlign
=
"Center"
/>
<
ItemStyle
Width
=
"30px"
HorizontalAlign
=
"Center"
/>
<
ItemTemplate
>
<
a
href
=
"#"
onclick
=
"ShowEditBrokerForm('<%# DataBinder.Eval(Container.DataItem, "
BrokerOfficeID") %>');"><
img
alt
=
""
src
=
"~/App_Themes/Images/edit.gif"
runat
=
"server"
border
=
"0"
></
a
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
CommandItemTemplate
>
<
a
href
=
"#"
onclick
=
"return ShowInsertBrokerForm();"
>Add New Broker</
a
>
</
CommandItemTemplate
>
</
MasterTableView
>
<
ClientSettings
AllowExpandCollapse
=
"true"
>
</
ClientSettings
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
</
telerik:RadGrid
>
</
telerik:RadPageView
>
Here are the javascript functions...
function
ShowEditBrokerContactForm(id1,id2) {
window.radopen(
"EditBrokerContact.aspx?BrokerOfficeID="
+ id1 +
"&BrokerContactID="
+ id2,
"UserListDialog"
);
return
false
;
}
function
ShowInsertBrokerContactForm(id) {
window.radopen(
"EditBrokerContact.aspx?BrokerOfficeID="
+ id,
"UserListDialog"
);
return
false
;
}