Telerik RadGrid + RadAjax管理器
我们直接说问题吧。
我有两个网格视图,其中一个网格视图生成另一个网格视图的数据源。两个网格视图都能够编辑项目(行),但编辑仅适用于第一个网格视图(为另一个网格视图生成数据的网格视图),当我单击第二个网格视图中的编辑时,什么也没有发生。我在网上搜索了一段时间并且(我相信)发现我需要的是 AJAX Manager。
我已经检查了 Telerik 网站上的几个示例/演示,但我仍然不确定如何在第二个 gridview 中进行编辑。当我单击第二个网格视图中的“编辑”按钮时,什么也没有发生。
两个 gridview 内部都有编辑表单,并且两个 gridview 的编辑表单类型都是“WebUserControl”。
目前 RadAjaxManager 看起来像这样:
<telerik:RadAjaxManager ID="ramAsseti" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="gvKontakti">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gvAsseti" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
有人可以帮我提供一些建议吗?任何帮助将不胜感激。
编辑:与此同时,我又添加了一个 RadGrid 并更新了 RadAjaxManager,我得到的是前两个 RadGrid 可以工作(我所说的“工作”是指我可以单击“编辑”并显示 UserControls),但最后一个不起作用。由于某些奇怪的原因,删除功能确实在最后一个 RadGrid (gvAsseti) 中工作。
这是代码(跳过边界字段,因为它们工作正常):
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="ramAsseti" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="gvTvrtke">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gvTvrtke" />
<telerik:AjaxUpdatedControl ControlID="gvKontakti" />
<telerik:AjaxUpdatedControl ControlID="gvAsseti" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="gvTvrtke" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellSpacing="0" GridLines="None" OnNeedDataSource="gvTvrtke_NeedDataSource"
OnItemCommand="gvTvrtke_ItemCommand">
<MasterTableView DataKeyNames="idFirma" CommandItemDisplay="TopAndBottom" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<CommandItemSettings AddNewRecordText="Dodaj novu tvrtku" RefreshText="Osvježi" />
<Columns>
<telerik:GridButtonColumn UniqueName="ShowAssetsColumn" ButtonType="LinkButton" DataTextFormatString="Kontakti"
DataTextField="idTvrtka" CommandName="ShowContacts">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn UniqueName="Naziv" DataField="Naziv" HeaderText="Naziv">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="OIB" HeaderText="OIB" DataField="OIB">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Tel1" HeaderText="Telefon 1" DataField="Tel1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Tel2" HeaderText="Telefon 2" DataField="Tel2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Fax" HeaderText="Fax" DataField="Fax">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Mob1" HeaderText="Mobitel 1" DataField="Mob1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Mob2" HeaderText="Mobitel 2" DataField="Mob2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email1" HeaderText="E-mail 1" DataField="Email1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email2" HeaderText="E-mail 2" DataField="Email2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Adresa1" HeaderText="Adresa" DataField="Adresa1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Web" HeaderText="Web" DataField="Web">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn UniqueName="Aktivan" HeaderText="Aktivan" DataField="Aktivan">
</telerik:GridCheckBoxColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete"
ConfirmDialogType="RadWindow" ConfirmText="Brisanje tvrtke!" />
</Columns>
<EditFormSettings UserControlName="UserControls/TvrtkaUserControl.ascx" EditFormType="WebUserControl">
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadGrid ID="gvKontakti" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Skin="Default" OnNeedDataSource="gvKontakti_NeedDataSource"
OnDeleteCommand="gvKontakti_DeleteCommand" OnInsertCommand="gvKontakti_InsertCommand"
OnPreRender="gvKontakti_PreRender" OnUpdateCommand="gvKontakti_UpdateCommand"
OnItemCommand="gvKontakti_ItemCommand">
<MasterTableView DataKeyNames="idKontakt" CommandItemDisplay="TopAndBottom" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<CommandItemSettings AddNewRecordText="Dodaj novi kontakt" RefreshText="Osvježi" />
<Columns>
<telerik:GridButtonColumn UniqueName="ShowAssetsColumn" ButtonType="LinkButton" DataTextFormatString="Asseti"
DataTextField="idKontakt" CommandName="ShowAssets">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn UniqueName="Kontakt" DataField="Naziv" HeaderText="Kontakt">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Funkcija" HeaderText="Funkcija" DataField="Funkcija">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Tel1" HeaderText="Telefon 1" DataField="Tel1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Tel2" HeaderText="Telefon 2" DataField="Tel2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Mob1" HeaderText="Mobitel 1" DataField="Mob1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Mob2" HeaderText="Mobitel 2" DataField="Mob2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email1" HeaderText="E-mail 1" DataField="Email1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email2" HeaderText="E-mail 2" DataField="Email2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Fax" HeaderText="Fax" DataField="Fax">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn UniqueName="Aktivan" HeaderText="Aktivan" DataField="Aktivan">
</telerik:GridCheckBoxColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete"
ConfirmDialogType="RadWindow" ConfirmText="Brisanje kontakta!" />
</Columns>
<EditFormSettings UserControlName="UserControls/KontaktUserControl.ascx" EditFormType="WebUserControl">
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadGrid ID="gvAsseti" runat="server" OnNeedDataSource="gvAsseti_NeedDataSource"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0"
GridLines="None" ondeletecommand="gvAsseti_DeleteCommand"
oninsertcommand="gvAsseti_InsertCommand"
onupdatecommand="gvAsseti_UpdateCommand">
<MasterTableView DataKeyNames="idAsset" CommandItemDisplay="TopAndBottom" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<CommandItemSettings AddNewRecordText="Dodaj novi asset" RefreshText="Prikaži sve assete" />
<Columns>
<telerik:GridBoundColumn UniqueName="Naziv" DataField="Naziv" HeaderText="Naziv">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Kod1" HeaderText="Kod 1" DataField="Kod1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Kod2" HeaderText="Kod 2" DataField="Kod">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="DatumGarancije" HeaderText="Datum garancije"
DataField="DatumGarancije">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn UniqueName="Aktivan" HeaderText="Aktivan" DataField="Aktivan">
</telerik:GridCheckBoxColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete"
ConfirmDialogType="RadWindow" ConfirmText="Brisanje asseta!" />
</Columns>
<EditFormSettings UserControlName="UserControls/AssetUserControl.ascx" EditFormType="WebUserControl">
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
Let's go straight to the problem.
I have two gridviews from which one generates the data source to another one. Both gridviews have ability to edit the item (row), but editing only works in first gridview (the one that generates data for the other one), when I click on edit in the second gridview nothing happens. I've been searching the web for a while and (I believe) found out that what I need is AJAX Manager.
I've checked couple of examples/Demos from Telerik's site, but I'm still not sure how to make editing in the second gridview work. When I click "Edit" button in second gridview nothing happens at all.
Both gridviews have edit forms inside and both gridview's edit form types are "WebUserControl".
Currently RadAjaxManager looks like this:
<telerik:RadAjaxManager ID="ramAsseti" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="gvKontakti">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gvAsseti" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
Could someone help me out with some suggestions. Any help would be appreciated.
EDIT: In the meantime I've added one more RadGrid and updated RadAjaxManager and what I got is that first two RadGrids work (by "work" I mean I can click Edit and UserControls are displayed), but the last one doesn't work. For some strange reason Delete function does work in the last RadGrid (gvAsseti).
Here is the code (skip boundfields as they work fine):
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="ramAsseti" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="gvTvrtke">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gvTvrtke" />
<telerik:AjaxUpdatedControl ControlID="gvKontakti" />
<telerik:AjaxUpdatedControl ControlID="gvAsseti" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="gvTvrtke" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellSpacing="0" GridLines="None" OnNeedDataSource="gvTvrtke_NeedDataSource"
OnItemCommand="gvTvrtke_ItemCommand">
<MasterTableView DataKeyNames="idFirma" CommandItemDisplay="TopAndBottom" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<CommandItemSettings AddNewRecordText="Dodaj novu tvrtku" RefreshText="Osvježi" />
<Columns>
<telerik:GridButtonColumn UniqueName="ShowAssetsColumn" ButtonType="LinkButton" DataTextFormatString="Kontakti"
DataTextField="idTvrtka" CommandName="ShowContacts">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn UniqueName="Naziv" DataField="Naziv" HeaderText="Naziv">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="OIB" HeaderText="OIB" DataField="OIB">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Tel1" HeaderText="Telefon 1" DataField="Tel1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Tel2" HeaderText="Telefon 2" DataField="Tel2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Fax" HeaderText="Fax" DataField="Fax">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Mob1" HeaderText="Mobitel 1" DataField="Mob1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Mob2" HeaderText="Mobitel 2" DataField="Mob2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email1" HeaderText="E-mail 1" DataField="Email1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email2" HeaderText="E-mail 2" DataField="Email2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Adresa1" HeaderText="Adresa" DataField="Adresa1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Web" HeaderText="Web" DataField="Web">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn UniqueName="Aktivan" HeaderText="Aktivan" DataField="Aktivan">
</telerik:GridCheckBoxColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete"
ConfirmDialogType="RadWindow" ConfirmText="Brisanje tvrtke!" />
</Columns>
<EditFormSettings UserControlName="UserControls/TvrtkaUserControl.ascx" EditFormType="WebUserControl">
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadGrid ID="gvKontakti" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Skin="Default" OnNeedDataSource="gvKontakti_NeedDataSource"
OnDeleteCommand="gvKontakti_DeleteCommand" OnInsertCommand="gvKontakti_InsertCommand"
OnPreRender="gvKontakti_PreRender" OnUpdateCommand="gvKontakti_UpdateCommand"
OnItemCommand="gvKontakti_ItemCommand">
<MasterTableView DataKeyNames="idKontakt" CommandItemDisplay="TopAndBottom" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<CommandItemSettings AddNewRecordText="Dodaj novi kontakt" RefreshText="Osvježi" />
<Columns>
<telerik:GridButtonColumn UniqueName="ShowAssetsColumn" ButtonType="LinkButton" DataTextFormatString="Asseti"
DataTextField="idKontakt" CommandName="ShowAssets">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn UniqueName="Kontakt" DataField="Naziv" HeaderText="Kontakt">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Funkcija" HeaderText="Funkcija" DataField="Funkcija">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Tel1" HeaderText="Telefon 1" DataField="Tel1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Tel2" HeaderText="Telefon 2" DataField="Tel2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Mob1" HeaderText="Mobitel 1" DataField="Mob1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Mob2" HeaderText="Mobitel 2" DataField="Mob2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email1" HeaderText="E-mail 1" DataField="Email1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email2" HeaderText="E-mail 2" DataField="Email2">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Fax" HeaderText="Fax" DataField="Fax">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn UniqueName="Aktivan" HeaderText="Aktivan" DataField="Aktivan">
</telerik:GridCheckBoxColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete"
ConfirmDialogType="RadWindow" ConfirmText="Brisanje kontakta!" />
</Columns>
<EditFormSettings UserControlName="UserControls/KontaktUserControl.ascx" EditFormType="WebUserControl">
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadGrid ID="gvAsseti" runat="server" OnNeedDataSource="gvAsseti_NeedDataSource"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0"
GridLines="None" ondeletecommand="gvAsseti_DeleteCommand"
oninsertcommand="gvAsseti_InsertCommand"
onupdatecommand="gvAsseti_UpdateCommand">
<MasterTableView DataKeyNames="idAsset" CommandItemDisplay="TopAndBottom" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<CommandItemSettings AddNewRecordText="Dodaj novi asset" RefreshText="Prikaži sve assete" />
<Columns>
<telerik:GridBoundColumn UniqueName="Naziv" DataField="Naziv" HeaderText="Naziv">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Kod1" HeaderText="Kod 1" DataField="Kod1">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Kod2" HeaderText="Kod 2" DataField="Kod">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="DatumGarancije" HeaderText="Datum garancije"
DataField="DatumGarancije">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn UniqueName="Aktivan" HeaderText="Aktivan" DataField="Aktivan">
</telerik:GridCheckBoxColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete"
ConfirmDialogType="RadWindow" ConfirmText="Brisanje asseta!" />
</Columns>
<EditFormSettings UserControlName="UserControls/AssetUserControl.ascx" EditFormType="WebUserControl">
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为如果你只是像这样将 gvAsseti 添加到 AJAX 设置中,它应该可以正常工作:
而不是这样:
执行此操作(注意每个网格都有一个 AjaxSetting):
另一种选择是使用RadAjaxPanel,并将所有网格放入其中。这将确保一切都是 AJAX:
I think if you just add gvAsseti to the AJAX settings like this, it should work fine:
Instead of this:
Do this (notice how there is an AjaxSetting for each grid):
Another alternative is to use a RadAjaxPanel, and put all of the grids inside of it. This will ensure that everything is AJAX: