1

让我们直奔问题。

我有两个网格视图,一个从中生成数据源到另一个。两个gridviews都能够编辑项目(行),但编辑只适用于第一个gridview(为另一个gridview生成数据的那个),当我在第二个gridview中单击edit时没有任何反应。我已经在网上搜索了一段时间,并且(我相信)发现我需要的是 AJAX 管理器。

我已经检查了 Telerik 网站上的几个示例/演示,但我仍然不确定如何在第二个 gridview 中进行编辑。当我在第二个 gridview 中单击“编辑”按钮时,什么也没有发生。

两个gridviews里面都有编辑表单,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),但最后一个不起作用. 出于某种奇怪的原因,Delete 函数在最后一个 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>
4

1 回答 1

6

我想如果你只是像这样将 gvAsseti 添加到 AJAX 设置中,它应该可以正常工作:

而不是这个:

<telerik:RadAjaxManager ID="ramAsseti" runat="server">
   <AjaxSettings>
       <telerik:AjaxSetting AjaxControlID="gvKontakti">
           <UpdatedControls>
               <!-- DON'T PUT THEM HERE -->
           </UpdatedControls>
       </telerik:AjaxSetting> 
   </AjaxSettings>
</telerik:RadAjaxManager>

这样做(注意每个 grid 有一个 AjaxSetting):

<telerik:RadAjaxManager ID="ramAsseti" runat="server">
   <AjaxSettings>
       <telerik:AjaxSetting AjaxControlID="gvKontakti" /> 
       <telerik:AjaxSetting AjaxControlID="gvAsseti" /> 
       <telerik:AjaxSetting AjaxControlID="gvTvrtke" />
   </AjaxSettings>
</telerik:RadAjaxManager>

另一种选择是使用 RadAjaxPanel,并将所有网格放入其中。这将确保一切都是 AJAX:

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">

   <telerik:RadGrid ... >

   <telerik:Radgrid ... >

   <telerik:RadGrid ... >

</telerik:RadAjaxPanel>
于 2011-08-25T15:37:26.337 回答