怎么获取nestedscrollview效果ViewTemplate内地值

Mobile App Development
Web Content Management
Software Quality
UI Components
App Development
JavaScript Hybrid Mobile
JavaScript Native Mobile
Reporting and QA
Reporting & Data
Testing & productivity
Member since:
Posted 09 Nov 2009
I have 3 grids nested inside a main grid using the NestedViewTemplate.
Everything works fine for binding and displaying the data.
The problem is I want to use a CommandItemTemplate in the nested grid to popup another window for inserting new parts.
I can make the
window pop-up, I just can not get the primary key from the top level grid to go with it.
I have tried all kinds of stuff, but I was hoping to do something like the snippet below to include the PlanID as an argument
to my javascript function:
&CommandItemTemplate&
&asp:Label ID="lblAddNewPart" Text="Add" runat="server"/&
&a href="#" onclick="return ShowAddPartForm('&%# Bind( "PlanID" ) %&');"&Add New &/a&
&/CommandItemTemplate&
I am open to C# code behind to set the onclick attributes or javascript to dig around if necessary to get the PlanID from
the parent grid or the nested grid, it exists in both.
I have inserted sample markup below if that helps.
(Sorry for the blue, I should have typed before using the format code block?)
&telerik:RadGrid ID="gridJobPlans" runat="server" DataSourceID="objJobPlans"
GridLines="None" AllowFilteringByColumn="True" AllowSorting="True"
AutoGenerateColumns="False"
onupdatecommand="gridJobPlans_UpdateCommand"
&MasterTableView DataKeyNames="ID"
DataSourceID="obj1" CommandItemDisplay="TopAndBottom"&
&NestedViewTemplate&
&asp:Label ID="PlanID" runat="server" Text='&%# Eval("ID") %&' /&
&telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="1"
MultiPageID="MultiPageSelectedJobPlan"&
&telerik:RadTab runat="server" Text="Documents"
PageViewID="SelectedJobPlanDocs"&
&/telerik:RadTab&
&/telerik:RadTabStrip&
&telerik:RadMultiPage ID="MultiPageSelectedJobPlan" Runat="server"
Width="703px" SelectedIndex="2"&
&telerik:RadPageView ID="Parts" runat="server"&
&telerik:RadGrid ID="Grid" runat="server"
AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True"
AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
DataSourceID="objSelected2" GridLines="None" AllowAutomaticDeletes="true"&
&MasterTableView AutoGenerateColumns="False" DataKeyNames="ID, PlanID"
CommandItemDisplay="TopAndBottom"&
&telerik:GridBoundColumn DataField="ID" DataType="System.Int64" HeaderText="ID"
ReadOnly="True" SortExpression="ID" UniqueName="ID" Display="false"&
&/telerik:GridBoundColumn&
&telerik:GridBoundColumn DataField="PlanID" DataType="System.Int64"
HeaderText="PlanID" SortExpression="PlanID" UniqueName="PlanID" Display="true"&
&/telerik:GridBoundColumn&
&/Columns&
&CommandItemTemplate&
&asp:Label ID="lblAddNewPart" Text="Add" runat="server"/&
&a href="#" onclick="return ShowAddPartForm('&%# Bind( "PlanID" ) %&');"&Add New &/a&
&/CommandItemTemplate&
&/MasterTableView&
&/telerik:RadGrid&
&/telerik:RadPageView&
&/telerik:RadMultiPage&
&/NestedViewTemplate&
&/MasterTableView&
&/telerik:RadGrid&
Member since:
Posted 10 Nov 2009
I figured out a solution if anyone comes across a similar situation.
There is probably a more elegant solution, but I have to keep going....
What I did was add the client ID of the label I am using in the nestedviewtemplate as the source parameter for all my nested grids in the code behind for the add new button in the nested grids.
Something like this:
1) Add the onitemcreated to get the CommandItemTemplate when it is created.
This must be added to the grid in the NestedView.
&telerik:RadGrid ID="Grid" runat="server"
AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True"
AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
OnUpdateCommand="GridUpdate"
DataSourceID="objSelected" GridLines="None" AllowAutomaticDeletes="true"
onitemcreated="grid_ItemCreated"&
Add the code behind to get the client ID of the label in the nested view, you can see the commented lines where I used the IE developer
tools to figure out what the ID comming in was and what it should be.
You can see that I am trying to get to PlanID, which is the label right at the top of the nested view.
That is the label with the parent ID that the nested tables are bound to.
protected void grid_ItemCreated(object sender, GridItemEventArgs e)
if (e.Item is GridCommandItem)
GridCommandItem commandItem = e.Item as GridCommandI
//replace the owner grid with the label I want
string lblID = commandItem.OwnerGridID.Replace("SelectedJobPlanPartsGrid", "");
lblID += "PlanID";
//"ctl00_Content_Page.ascx_gridJobPlans_ctl00_ctl06_Grid"
//ctl00_Content_Page.ascx_gridJobPlans_ctl00_ctl06_PlanID
LinkButton lbl = commandItem.FindControl("lblAddNew") as LinkB
string temp = "return ShowAddForm('" + lblID + "');";
lbl.Attributes.Add("onclick", temp);
Add the javascript to get the value.
It is actually in a Span rather than a label when it is finally displayed to the client.
function ShowAddForm(PlanID) {
var theDiv = document.getElementById(PlanID);
window.radopen("AddNew.aspx?PlanID=" + theDiv.innerHTML, "AddNewDialog");
4) I think the only thing I forgot was the CommandItemTemplate that goes inside the nested grid.
&CommandItemTemplate&
&asp:LinkButton ID="lblAddNew" Text="Add New" runat="server"&&/asp:LinkButton&
&/CommandItemTemplate&
If anyone wants me to attach a sample solution I can.
Otherwise I would still like to hear other ways to do this.
Phil DeVeau
Member since:
Posted 08 Dec 2009
I've got the have you found a better way to do this?
Member since:
Posted 08 Dec 2009
Sorry, I can't be of more help on this one.
I decided I did not like how it was done and started over with an inline insert.
I added the Parent Primary key as a hidden (display=false) bound column in the columns collection of the nested grid and enabled automatic inserts.
Member since:
Posted 09 Apr 2012
just came across similar issue 3 years on : )
used above method (so thanks for that!!!)
just changed the part where we're trying to derive the client IDs in favor of just looking to the parent ...
protected void grid_ItemCreated(object sender, GridItemEventArgs e) &
& & & & {&
& & & & & & if (e.Item is GridCommandItem) &
& & & & & & { &
& & & & & & & & GridCommandItem commandItem = e.Item as GridCommandI &
& & & & & & & & &
RadGrid rg = (RadGrid)
& & & & & & & & RadPageView pv = (RadPageView)rg.P
& & & & & & & & Label lblcid = (Label)pv.FindControl("PlanID");
& & & & & & & & Int32 intPlanID= Int32.Parse(lblcid.Text);
& & & & & & & & LinkButton lbl = commandItem.FindControl("lblAddNew") as LinkB &
& & & & & & & & string temp = "return ShowAddForm('" + intPlanID&+ "');"; &
& & & & & & & & lbl.Attributes.Add("onclick", temp); &
& & & & & & } &
& & & & }&
Get Products
Recognition
USA: +1 888 365 2779
India: +91 124 4300987
Bulgaria: +359 2 8099850
Australia: +61 3
Copyright & 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See
or appropriate markings.
Powered by}

我要回帖

更多关于 nestedscrollview用法 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信