开发者

Telerik RadGrid + RadAjaxManager

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>


I think if you just add gvAsseti to the AJAX settings like this, it should work fine:

Instead of this:

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

Do this (notice how there is an AjaxSetting for each grid):

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

Another alternative is to use a RadAjaxPanel, and put all of the grids inside of it. This will ensure that everything is AJAX:

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

   <telerik:RadGrid ... >

   <telerik:Radgrid ... >

   <telerik:RadGrid ... >

</telerik:RadAjaxPanel>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜