This is a migrated thread and some comments may be shown as answers.

Edit with UserControl : After Insert don't hide the usercontrol

7 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lupotana
Top achievements
Rank 1
lupotana asked on 27 Jul 2011, 11:38 AM
Hi, i'm studying the example
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx

I replace all and it's ok, one thing is wrong in my example, when I add a new record after confirm the usercontrol don't hide as in Update event.
The usercontrol after confirm insert is cleared but is visible in grid.

I can try with
e.Canceled = true;
 
gvList.SelectedIndexes.Clear();
 
this.gvList.MasterTableView.Rebind();
in the InsertCommand of RadGrid but don't work.

This is my RadGrid
<telerik:RadGrid ID="gvList" runat="server" AllowPaging="True" AllowSorting="True"
                            ShowStatusBar="True" CellSpacing="0" GridLines="None" Skin="Office2010Blue" AutoGenerateColumns="False"
                            OnNeedDataSource="gvList_NeedDataSource" OnDeleteCommand="gvList_DeleteCommand"
                            AllowAutomaticUpdates="false" PageSize="20" OnInsertCommand="gvList_InsertCommand"
                            OnUpdateCommand="gvList_UpdateCommand">
                            <HeaderStyle Font-Bold="true" />
                            <MasterTableView CommandItemDisplay="Top" DataKeyNames="d61_n_tipo" AllowAutomaticInserts="True"
                                CommandItemSettings-AddNewRecordImageUrl="Images/Grid/add2.png" CommandItemSettings-AddNewRecordText="AGGIUNGI NUOVA TIPOLOGIA"
                                CommandItemSettings-RefreshImageUrl="Images/Grid/refresh.png" CommandItemSettings-RefreshText="AGGIORNA LISTA">
                                <Columns>
                                    <telerik:GridBoundColumn DataField="d61_n_tipo" UniqueName="d61_n_tipo" Visible="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="d61_n_tipo" HeaderText="CODICE">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="d61_c_descrizione" HeaderText="DESCRIZIONE">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="d60_c_descrizione" HeaderText="TIPI BASE">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridCheckBoxColumn DataField="d61_n_flag_obsoleto" HeaderText="OBSOLETO">
                                    </telerik:GridCheckBoxColumn>
                                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" EditImageUrl="~/Images/Grid/edit.png"
                                        EditText="Modifica" ItemStyle-HorizontalAlign="Center" ButtonType="ImageButton"
                                        ItemStyle-Width="3%">
                                    </telerik:GridEditCommandColumn>
                                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow"
                                        ConfirmText="Confermare l'eliminazione del record ?" ConfirmTitle="Conferma eliminazione"
                                        ImageUrl="~/Images/Grid/delete2.png" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="3%"
                                        Text="Elimina" UniqueName="DeleteColumn">
                                        <ItemStyle HorizontalAlign="Center" Width="3%" />
                                    </telerik:GridButtonColumn>
                                </Columns>
                                <EditFormSettings UserControlName="ucGridTipologieUfficiali.ascx" EditFormType="WebUserControl">
                                    <EditColumn UniqueName="EditCommandColumn1">
                                    </EditColumn>
                                </EditFormSettings>
                            </MasterTableView>
                            <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                            </ClientSettings>
                            <FilterMenu EnableImageSprites="False">
                            </FilterMenu>
                        </telerik:RadGrid>

Thanks,
Marco




7 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 01 Aug 2011, 02:53 PM
Hello Marco,

This happens because you try to use automatic datasource operations when the grid is bound using programmatic binding. As you can read in this help article, automatic operations are supported only with declarative datasource controls configured to enable them:
Automatic DataSource Operations

When you have programmatic binding, you need to handle data editing manually, for example:
Inserting Values Using UserControl/FormTemplate

Kind regards,
Tsvetina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
lupotana
Top achievements
Rank 1
answered on 21 Sep 2011, 11:59 AM
I still have some doubts.
My problem is only visual.

When I insert a record (InserCommand) I force the closure of the panel insert in this way:

GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
           insertedItem.Visible = false;
           insertedItem.Enabled = false;
           e.Item.OwnerTableView.ClearEditItems();


So far so good.
If you edit a record in addition to the Update panel reappears to insert.
There is no way to hide only the Insert panel, I can not change the architecture of amla data for presentation on a vision problem.

I am attaching a picture
0
Tsvetina
Telerik team
answered on 26 Sep 2011, 01:47 PM
Hi Marco,

The grid can be taken out of insert mode using:
e.Item.OwnerTableView.IsItemInserted = false;
gvList.Rebind();

However, you would still need to set  the AllowAutomaticInsert/Update/Delete properties to false if you are using programmatic binding for your grid. Also, not being able to close the insert form is not that much of a visual problem as it is an indicator of an issue in your insertion logic.

Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
lupotana
Top achievements
Rank 1
answered on 07 Oct 2011, 02:47 PM
 

Posted on Sep 26, 2011

Hi Marco,

The grid can be taken out of insert mode using:
e.Item.OwnerTableView.IsItemInserted = false;
gvList.Rebind();

Don't hide the insert panel after click edit button.

The problem happens where I insert a record (the panel correct hide) and before I edit a record in grid.
The gird open the "edit usercontrol" but also the "new usercontrol".
I don't want open the "new modality" when click edit.

<telerik:RadGrid ID="gvList" runat="server" AllowPaging="True" AllowSorting="True"
                           ShowStatusBar="True" CellSpacing="0" GridLines="None" Skin="Office2010Blue" AutoGenerateColumns="False"
                           OnNeedDataSource="gvList_NeedDataSource" OnDeleteCommand="gvList_DeleteCommand"
                           PageSize="20" OnInsertCommand="gvList_InsertCommand" OnUpdateCommand="gvList_UpdateCommand">
                           <HeaderStyle Font-Bold="true" />
                           <ExportSettings FileName="Esempio" IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true">
                               <Pdf PaperSize="A4" Author="Marco Bianchi" AllowPrinting="true" Creator="Marco Bianchi"
                                   AllowModify="true" AllowCopy="true" AllowAdd="true" PageWidth="210mm" PageHeight="297mm"
                                   PageLeftMargin="1mm" PageBottomMargin="5mm" PageRightMargin="1mm" PageTopMargin="18mm" />
                               <Excel Format="Html" />
                           </ExportSettings>
                           <MasterTableView AllowAutomaticInserts="True" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordImageUrl="~/Images/Grid/add2.png"
                               CommandItemSettings-AddNewRecordText="AGGIUNGI NUOVA TIPOLOGIA" CommandItemSettings-RefreshImageUrl="~/Images/Grid/refresh.png"
                               CommandItemSettings-RefreshText="AGGIORNA LISTA" DataKeyNames="CODE">
                               <CommandItemSettings AddNewRecordImageUrl="~/Images/Grid/add2.png" AddNewRecordText="AGGIUNGI NUOVA TIPOLOGIA"
                                   ExportToPdfText="Export to PDF" RefreshImageUrl="~/Images/Grid/refresh.png" RefreshText="AGGIORNA LISTA" />
                               <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                               </RowIndicatorColumn>
                               <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                               </ExpandCollapseColumn>
                               <Columns>
                                   <telerik:GridBoundColumn DataField="CODE" UniqueName="CODE" HeaderText="CODE"
                                       HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                   </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn DataField="DESCRIPTION" HeaderText="DESCRIPTION" ItemStyle-HorizontalAlign="Center">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridCheckBoxColumn DataField="d61_n_flag_obsoleto" HeaderText="OBSOLETO"
                                       UniqueName="Obsoleto" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                   </telerik:GridCheckBoxColumn>
                                   <telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="~/Images/Grid/edit.png"
                                       EditText="Modifica" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="3%" UniqueName="EditCommandColumn">
                                       <ItemStyle HorizontalAlign="Center" Width="3%" />
                                   </telerik:GridEditCommandColumn>
                                   <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow"
                                       ConfirmText="Confermare l'eliminazione del record ?" ConfirmTitle="Conferma eliminazione"
                                       ImageUrl="~/Images/Grid/delete2.png" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="3%"
                                       Text="Elimina" UniqueName="DeleteColumn">
                                       <ItemStyle HorizontalAlign="Center" Width="3%" />
                                   </telerik:GridButtonColumn>
                               </Columns>
                               <EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControlGrid/ucGridTipologieUfficialiDesignabili.ascx">
                                   <EditColumn UniqueName="EditCommandColumn1">
                                   </EditColumn>
                               </EditFormSettings>
                           </MasterTableView>
                           <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                               <Selecting AllowRowSelect="True" />
                           </ClientSettings>
                           <FilterMenu EnableImageSprites="False">
                           </FilterMenu>
                       </telerik:RadGrid>

iN C#
1 ON 4
private void PopulateGridView()
   {
       DataTable dt = item.GetCollectionCustom();
       gvList.DataSource = dt;
       WebToolTelerik.SetLanguageGrid(ref gvList);
   }

2 on 4
protected void gvList_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        PopulateGridView();
    }

3 on 4
protected void gvList_InsertCommand(object sender, GridCommandEventArgs e)
    {
        try
        {
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            item = new BusinessClass();
            item.CODE= short.Parse((userControl.FindControl("txtCode") as RadNumericTextBox).Value.ToString());
            item.Description= (userControl.FindControl("txtDescription") as RadTextBox).Text;
                 item.Insert();
  
            PopulateGridView();
            gvList.DataBind();
  
            GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
            insertedItem.Visible = false;
            insertedItem.Enabled = false;
            e.Item.OwnerTableView.ClearEditItems();
  
            plusNotificationOk.Title = StaticMessage.TitleSuccess;
            plusNotificationOk.Text = StaticMessage.InsertMessage;
            plusNotificationOk.Show();
        }
}

4 on 4
protected void gvList_UpdateCommand(object sender, GridCommandEventArgs e)
    {
        try
        {
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            string code = (userControl.FindControl("txtCode") as RadNumericTextBox).Value.ToString();
            short sCode = short.Parse(code);
            item = new BusinessClass().GetByCode(sCode);
            item.DESCRIPTION= (userControl.FindControl("txtDescription") as RadTextBox).Text;
            item.Update();
  
            plusNotificationOk.Title = StaticMessage.TitleSuccess;
            plusNotificationOk.Text = StaticMessage.UpdateMessage;
            plusNotificationOk.Show();
        }
}

I need help :-)
I'm an user with License... We want my usernamen for spend a premium support ticket ?

0
Tsvetina
Telerik team
answered on 10 Oct 2011, 12:13 PM
Hi Lupotana,

You still have AllowAutomaticInserts set to True in your MasterTableView declaration. Remove it from there, too, and let us know if the issue persists.

As for submitting a support ticket, if you do not know the credentials for your licenced account, you should contact the licence holder in your company and request them from him.

Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
lupotana
Top achievements
Rank 1
answered on 12 Oct 2011, 05:09 PM
Hi I fixed the problem.

I set the property AllowAutomaticInserts = false but the problem remained.
I try to delete the property AllowAutomaticInserts from HTML and and everything works now.

Is it a bug?

Thanks a lot.

Marco
0
Tsvetina
Telerik team
answered on 13 Oct 2011, 02:13 PM
Hi Lupotana,

I did not manage to reproduce such behavior in the latest version of RadControls. The problem may have exposed due to caching or unsaved changes, I am not sure why exactly but we could not find and have not been reported this kind of issue.

Kind regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
lupotana
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
lupotana
Top achievements
Rank 1
Share this question
or