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

Only 1 edit column on Add New

4 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 2
Stefan asked on 28 Jun 2013, 09:43 PM
I have a radgrid in batch edit mode.  When I click on add new I only get 1 column to edit even though I have 2 visible columns?

Also the Add New resizes my grid by 1/2 to say Save Changed even though I have plenty of space to keep it all on one line? 

Third I can not get any of the command events to fire except BatchEdit Command??


                                                 <telerik:RadGrid ID="dgCompNonGrid" GridLines="None" runat="server" AllowAutomaticDeletes="True"
                                                    AllowAutomaticInserts="True" PageSize="40" Skin="Default" OnItemDeleted="dgCompNonGrid_ItemDeleted" OnItemInserted="dgCompNonGrid_ItemInserted"
                                                    OnItemUpdated="dgCompNonGrid_ItemUpdated" AllowAutomaticUpdates="True" AllowPaging="False"
                                                    AutoGenerateColumns="False" Width="440px" OnBatchEditCommand="dgCompNonGrid_BatchEditCommand" Height="230px">
                                                     <ExportSettings>
                                                         <Pdf>
                                                             <PageHeader>
                                                                 <LeftCell Text="" />
                                                                 <MiddleCell Text="" />
                                                                 <RightCell Text="" />
                                                             </PageHeader>
                                                             <PageFooter>
                                                                 <LeftCell Text="" />
                                                                 <MiddleCell Text="" />
                                                                 <RightCell Text="" />
                                                             </PageFooter>
                                                         </Pdf>
                                                     </ExportSettings>
                                                    <ClientSettings>
                                                        <Selecting AllowRowSelect="True" />
                                                    </ClientSettings>
                                                    <MasterTableView AllowNaturalSort="False"  EditMode="Batch" BatchEditingSettings-OpenEditingEvent ="DblClick">
                                                        <BatchEditingSettings EditType="Cell" />
                                                        <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                                                        </RowIndicatorColumn>
                                                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                                                        </ExpandCollapseColumn>
                                                        <EditFormSettings>
                                                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                            </EditColumn>
                                                        </EditFormSettings>
                                                        <PagerStyle PageSizeControlType="RadComboBox" />
                                                    </MasterTableView>
                                                     <MultiHeaderItemStyle Wrap="False" />
                                                     <ItemStyle Wrap="False" />
                                                    <PagerStyle PageSizeControlType="RadComboBox" />
                                                    <FilterMenu EnableImageSprites="False">
                                                    </FilterMenu>
                                                </telerik:RadGrid>

CODE==================================================================================

           With dgCompNonGrid
                .Columns.Clear()
                .DataSource = Nothing
                .DataSource = ippService.SelectPlanComponentsDetails(iCompID)
            End With

            Dim boundColumn As GridBoundColumn

            boundColumn = New GridBoundColumn()
            dgCompNonGrid.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ippComponentID"
            boundColumn.UniqueName = "dgippComponentID"
            boundColumn.Display = False
            boundColumn.HeaderText = ""
            boundColumn.ItemStyle.Font.Size = 8
            boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left
            boundColumn.ReadOnly = True

            boundColumn = New GridBoundColumn()
            dgCompNonGrid.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ippComponentSeq"
            boundColumn.UniqueName = "dgippComponentSeq"
            boundColumn.Display = False
            boundColumn.HeaderText = ""
            boundColumn.ItemStyle.Font.Size = 8
            boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

            boundColumn = New GridBoundColumn()
            dgCompNonGrid.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ippComponentSrcValue"
            boundColumn.UniqueName = "dgippComponentSrcValue"
            boundColumn.Display = True
            boundColumn.HeaderText = "Value"
            boundColumn.ItemStyle.Font.Size = 8
            boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

            boundColumn = New GridBoundColumn()
            dgCompNonGrid.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ippComponentBonusPct"
            boundColumn.UniqueName = "dgippComponentBonusPct"
            boundColumn.Display = True
            boundColumn.HeaderText = "Bonus %"
            boundColumn.ItemStyle.Font.Size = 8
            boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

            Dim oDeleteColumn As New GridButtonColumn

            With oDeleteColumn
                .UniqueName = "Delete"
                .HeaderText = "Remove"
                .ItemStyle.Font.Size = 8
                .ButtonType = GridButtonColumnType.ImageButton
                .ImageUrl = "~/Images/style7/cancel.gif"
                .Display = True
                .Visible = True
                .CommandName = "Delete"
                .ConfirmText = "Delete this increment?"
                .ConfirmDialogType = GridConfirmDialogType.RadWindow
                .ItemStyle.HorizontalAlign = HorizontalAlign.Left
            End With

            dgCompNonGrid.MasterTableView.Columns.Add(oDeleteColumn)

            dgCompNonGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top


4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 01 Jul 2013, 06:08 AM
Hi Stefan,

I have tried to replicate your issue but it works fine.Please check the below example code snippet.The events are fired after you click SaveChanges.

ASPX:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
  </telerik:RadScriptManager>
  <telerik:RadListBox runat="server" ID="SavedChangesList" Width="600px" Height="200px"
      Visible="false">
  </telerik:RadListBox>
  <telerik:RadGrid ID="Radgrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
      AllowAutomaticInserts="True"  OnItemDeleted="Radgrid1_ItemDeleted"
      OnItemInserted="Radgrid1_ItemInserted" OnItemUpdated="Radgrid1_ItemUpdated"
      AllowAutomaticUpdates="True"  AutoGenerateColumns="False" 
      OnBatchEditCommand="RadGrid1_BatchEditCommand" OnInit="OnInit">
      <MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="ProductID" 
          EditMode="Batch" AutoGenerateColumns="False">
          <BatchEditingSettings EditType="Cell" />
          <SortExpressions>
              <telerik:GridSortExpression FieldName="ProductID" SortOrder="Descending" />
          </SortExpressions>
      </MasterTableView>
  </telerik:RadGrid>
  <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Northwind_newConnectionString3 %>"
      DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = @ProductID" InsertCommand="INSERT INTO [Products] ([ProductName], [CategoryID]) VALUES (@ProductName, @CategoryID)"
      SelectCommand="SELECT [ProductID], [ProductName], [Products].[CategoryID], [Categories].[CategoryName] as CategoryName FROM [Products] JOIN Categories ON Products.CategoryID=Categories.CategoryID"
      UpdateCommand="UPDATE [Products] SET [ProductName] = @ProductName, [CategoryID] = @CategoryID WHERE [ProductID] = @ProductID">
      <DeleteParameters>
          <asp:Parameter Name="ProductID" Type="Int32"></asp:Parameter>
      </DeleteParameters>
      <InsertParameters>
          <asp:Parameter Name="ProductName" Type="String"></asp:Parameter>
          <asp:Parameter Name="CategoryID" Type="Int32"></asp:Parameter>
      </InsertParameters>
      <UpdateParameters>
          <asp:Parameter Name="ProductName" Type="String"></asp:Parameter>
          <asp:Parameter Name="CategoryID" Type="Int32"></asp:Parameter>
      </UpdateParameters>
  </asp:SqlDataSource>

VB:
Protected Sub OnInit(sender As Object, e As EventArgs)
 
    Radgrid1.DataSource = SqlDataSource2
    Dim boundColumn As GridBoundColumn
    boundColumn = New GridBoundColumn()
    Radgrid1.MasterTableView.Columns.Add(boundColumn)
    boundColumn.DataField = "ProductName"
    boundColumn.UniqueName = "ProductName"
    boundColumn.Display = True
    boundColumn.HeaderText = "ProductName"
    boundColumn.ItemStyle.Font.Size = 8
    boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left
 
    boundColumn = New GridBoundColumn()
    Radgrid1.MasterTableView.Columns.Add(boundColumn)
    boundColumn.DataField = "CategoryID"
    boundColumn.UniqueName = "CategoryID"
    boundColumn.Display = True
    boundColumn.HeaderText = "CategoryID"
    boundColumn.ItemStyle.Font.Size = 8
    boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left
 
    Dim oDeleteColumn As New GridButtonColumn()
    If True Then
        oDeleteColumn.UniqueName = "Delete"
        oDeleteColumn.HeaderText = "Remove"
        oDeleteColumn.ItemStyle.Font.Size = 8
        oDeleteColumn.ButtonType = GridButtonColumnType.ImageButton
        oDeleteColumn.ImageUrl = "~/Images/style7/cancel.gif"
        oDeleteColumn.Display = True
        oDeleteColumn.Visible = True
        oDeleteColumn.CommandName = "Delete"
        oDeleteColumn.ConfirmText = "Delete this increment?"
        oDeleteColumn.ConfirmDialogType = GridConfirmDialogType.RadWindow
        oDeleteColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left
    End If
 
    Radgrid1.MasterTableView.Columns.Add(oDeleteColumn)
    Radgrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top
 
End Sub
Protected Sub Radgrid1_ItemDeleted(sender As Object, e As GridDeletedEventArgs)
    'Your Codes
End Sub
Protected Sub Radgrid1_ItemInserted(sender As Object, e As GridInsertedEventArgs)
    'Your Codes
End Sub
Protected Sub Radgrid1_ItemUpdated(sender As Object, e As GridUpdatedEventArgs)
    'Your Codes
End Sub
Protected Sub RadGrid1_BatchEditCommand(sender As Object, e As Telerik.Web.UI.GridBatchEditingEventArgs)
    'Your Codes
End Sub

Thanks,
Princy
0
Stefan
Top achievements
Rank 2
answered on 03 Jul 2013, 02:52 PM
When I Click Add New only 1 edit box is available?  It must be something simple.  I have just barebones code below to see if you can see why this is happening?  Also the only event that fires is the BatchEditCommand.

<body>
    <form id="form1" runat="server">
        <div>

            <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />

        </div>

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>

        <telerik:RadGrid ID="dgCompNonGrid" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" OnItemDeleted="dgCompNonGrid_ItemDeleted"
            OnItemInserted="dgCompNonGrid_ItemInserted" OnItemUpdated="dgCompNonGrid_ItemUpdated"
            AllowAutomaticUpdates="True" AutoGenerateColumns="False"
            OnBatchEditCommand="dgCompNonGrid_BatchEditCommand" Width="100%">
            <ClientSettings>
                <Selecting AllowRowSelect="True" />
            </ClientSettings>
            <MasterTableView AllowNaturalSort="False" EditMode="Batch" BatchEditingSettings-OpenEditingEvent="DblClick">
                <BatchEditingSettings EditType="Cell" />
            </MasterTableView>
            <MultiHeaderItemStyle Wrap="False" />
            <ItemStyle Wrap="False" />
        </telerik:RadGrid>

    </form>
</body>

CODE-------------------------
    Public Sub Load_Component_NonGrid(ByVal iCompID As Int32, Init As Boolean)

        'Dim dt As DataTable = New DataTable
        'Dim ods As DataSet

        'If Not IsPostBack Then
        If iCompID > 0 Then

            With dgCompNonGrid
                .Columns.Clear()
                .DataSource = Nothing
                .DataSource = ippService.SelectPlanComponentsDetails(iCompID)
            End With

            Dim boundColumn As GridBoundColumn

            boundColumn = New GridBoundColumn()
            dgCompNonGrid.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ippComponentID"
            boundColumn.UniqueName = "dgippComponentID"
            boundColumn.Display = True
            boundColumn.HeaderText = ""
            boundColumn.ItemStyle.Font.Size = 8
            'boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left
            boundColumn.ReadOnly = True

            boundColumn = New GridBoundColumn()
            dgCompNonGrid.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ippComponentSeq"
            boundColumn.UniqueName = "dgippComponentSeq"
            boundColumn.Display = True
            boundColumn.HeaderText = ""
            boundColumn.ItemStyle.Font.Size = 8
            boundColumn.ReadOnly = False
            'boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

            boundColumn = New GridBoundColumn()
            dgCompNonGrid.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ippComponentSrcValue"
            boundColumn.UniqueName = "dgippComponentSrcValue"
            boundColumn.Display = True
            boundColumn.HeaderText = "Value"
            boundColumn.ItemStyle.Font.Size = 8
            boundColumn.ReadOnly = False
            'boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

            boundColumn = New GridBoundColumn()
            dgCompNonGrid.MasterTableView.Columns.Add(boundColumn)
            boundColumn.DataField = "ippComponentBonusPct"
            boundColumn.UniqueName = "dgippComponentBonusPct"
            boundColumn.Display = True
            boundColumn.HeaderText = "Bonus %"
            boundColumn.ItemStyle.Font.Size = 8
            boundColumn.ReadOnly = False
            'boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

            Dim oDeleteColumn As New GridButtonColumn

            With oDeleteColumn
                .UniqueName = "Delete"
                .HeaderText = "Remove"
                .ItemStyle.Font.Size = 8
                .ButtonType = GridButtonColumnType.ImageButton
                .ImageUrl = "~/Images/style7/cancel.gif"
                .Display = True
                .Visible = True
                .CommandName = "Delete"
                .ConfirmText = "Delete this increment?"
                .ConfirmDialogType = GridConfirmDialogType.RadWindow
                .ItemStyle.HorizontalAlign = HorizontalAlign.Left
            End With

            dgCompNonGrid.MasterTableView.Columns.Add(oDeleteColumn)

            dgCompNonGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top

        End If
        ' End If

    End Sub

    Protected Sub dgCompNonGrid_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles dgCompNonGrid.NeedDataSource

        Load_Component_NonGrid(1095, False)

    End Sub





0
Stefan
Top achievements
Rank 2
answered on 03 Jul 2013, 03:05 PM
Nevermind I figured it out but it seems to be a bug in the grid while in batch edit mode.

I have the edittype set to CELL because I wanted to edit one cell at a time. 

So when I click on ADD NEW it only lets me add one column/cell of the row.  So Add new should know that I need to add all the columns that are visible.  Since I can't add an entire row if it only lets me add one cell???  Add New should over-ride the edittype to Row even when set to cell.

If I change edit type to ROW now I can add all columns that I need for a NEW row.

But when I go to edit a cell on double click it puts all the cells in edit mode instead of just the one cell.


Unless I am missing something Add New Record should over-ride the edit type to ROW when set to cell??

0
Angel Petrov
Telerik team
answered on 08 Jul 2013, 09:56 AM
Hello Stefan,

I have to say that this is the default behavior of the Cell EditType. When you click on the Add New Record button a new row will be inserted into the grid and only one editor for in row will be displayed. As you can see the same behavior which you are experiencing can be reproduced using the online demo. The idea is to edit only one cell at a time when using the Cell EditType.

Regards,
Angel Petrov
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Stefan
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Stefan
Top achievements
Rank 2
Angel Petrov
Telerik team
Share this question
or