Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
678 views

Hello

I have a RadGrid ("rgPart") with Insert, Edit and Delete implemented on it and fully functional.

I have been trying to move those commands to modals independent from the radgrid, so far I have been able to implement modals for Insert and Delete, but Im having problems with showing the information of the radgrid into de Edit modal textboxes.

Anyone can help me with that?

 

RadGrid Code:

 

<asp:ImageButton ID="btnInsertar" runat="server"   OnClick="btnInsertar_Click" CommandName="InitInsert" ImageUrl="~/images/add.png" />

 

 <asp:UpdatePanel ID="upPart" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                    <ContentTemplate>
                        
                        <telerik:RadGrid ID="rgPart" runat="server" GroupingSettings-CaseSensitive="false"  AllowPaging="True" RenderMode="Lightweight"
                            AllowSorting="true" AllowFilteringByColumn="True"  PageSize="10 " OnNeedDataSource="rgPart_NeedDataSource" OnItemCommand="ItemCommand" OnItemDataBound="rgPart_ItemDataBound"
                                CssClass="RadGrid_Silk" EnableHeaderContextMenu="true" GridLines="Horizontal" Width="100%" AllowAutomaticDeletes="True" AllowAutomaticInserts="False" AllowAutomaticUpdates="False">
                            <HeaderContextMenu Enabled="false"></HeaderContextMenu>
                            <MasterTableView AutoGenerateColumns="false" DataKeyNames="IdPartNumber" ItemStyle-HorizontalAlign="Center" AlternatingItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" CommandItemDisplay="Top" NoMasterRecordsText="<%$ Resources:Language, lbl_tablaVacia %>">
                                <CommandItemSettings AddNewRecordImageUrl="~/images/add.png" AddNewRecordText="" RefreshText="<%$ Resources:Language, lbl_actualizar %>"/>
                                <Columns>
                                    <telerik:GridBoundColumn DataField="IdPartNumber" HeaderText="ID" ReadOnly="true" Display="false" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" ></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Part" HeaderText="<%$ Resources:Language, lbl_rg_part %>" Display="true" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
                                    
                                    <telerik:GridEditCommandColumn UniqueName="EditColumn" CancelText="Cancel" UpdateText="Update" InsertText="Insert" EditText="Edit" EditFormColumnIndex="3" ButtonType="ImageButton" EditImageUrl="~/images/edit.png">
                                    </telerik:GridEditCommandColumn>

                                   <telerik:GridTemplateColumn DataField="" HeaderText=""  HeaderStyle-Width="3%"  AllowFiltering="false">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="imgEditar" runat="server" CausesValidation="False" CommandArgument='<%# Eval("IdPartNumber") %>' CommandName="Editar" ImageUrl="~/images/edit.png"  ItemStyle-Wrap="True"  
                                                OnClientClick="btnEditar_Click"/>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" Width="3%" />
                                    </telerik:GridTemplateColumn>

                                    <telerik:GridTemplateColumn DataField="" HeaderText=""  HeaderStyle-Width="3%"  AllowFiltering="false">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="imgEliminar" runat="server" CausesValidation="False" CommandArgument='<%# Eval("IdPartNumber") %>' CommandName="Delete" ImageUrl="~/images/delete.png" Width="30px" Height="30px" ItemStyle-Wrap="True"  ToolTip="<%$ Resources:Language, tt_eliminar %>" 
                                                OnClientClick="javascript:if(!confirm('Eliminar/Delete')){return false;}"/>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" Width="3%" />
                                    </telerik:GridTemplateColumn>
                                </Columns>
                               
                            </MasterTableView>
                        </telerik:RadGrid>
                    </ContentTemplate>
                </asp:UpdatePanel>

 

Modal Insert Code

<div class="modal fade" id="mdlPartInsert" role="dialog" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                <ContentTemplate>
                    <div class="modal-content">
                        <div class="modal-header">
                        </div>
                        <div class="modal-body text-center">
                            <div class="row">
                                <asp:Label for="txtIdpn" CssClass="col-12 text-left lbl_form" ID="Label1" runat="server" Text="<%$ Resources:Language, lbl_rg_part%>" ForeColor="Black"></asp:Label>
                                <div class="col-12 text-left">
                                    <asp:TextBox ID="txtIdpn" runat="server" CssClass="form-control form-control-sm"></asp:TextBox>
                                </div>
                            </div>
                            <div class="row">
                                <asp:Label for="txtPn" CssClass="col-12 text-left lbl_form" ID="Label3" runat="server" Text="<%$ Resources:Language, lbl_rg_pn %>" ForeColor="Black"></asp:Label>
                                <div class="col-12 text-left">
                                    <asp:TextBox ID="txtPn" runat="server" CssClass="form-control form-control-sm"></asp:TextBox>
                                </div>
                            </div>
                        <div class="modal-footer">
                            <asp:Button ID="btnAutorizar" CssClass="btn btn-info btn-sm" runat="server" Text="<%$ Resources:Language, btn_Autorizar %>" OnClick="btnAutorizar_OnClick" />
                            <asp:Button ID="btnCancelar" CssClass="btn btn-danger btn-sm" runat="server" Text="<%$ Resources:Language, btn_Cancelar %>" OnClick="btnCancelar_OnClick" />
                        </div>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>

 

Modal Edit Code

<div class="modal fade" id="mdlPartEdit" role="dialog" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                <ContentTemplate>
                    <div class="modal-content">
                        <div class="modal-header">
                        </div>
                        <div class="modal-body text-center">
                            <div class="row">
                                <asp:Label for="editIdpn" CssClass="col-12 text-left lbl_form" ID="Label7" runat="server" Text="<%$ Resources:Language, lbl_rg_part%>" ForeColor="Black"></asp:Label>
                                <div class="col-12 text-left">
                                    <asp:TextBox ID="editIdpn" runat="server" CssClass="form-control form-control-sm"></asp:TextBox>
                                </div>
                            </div>
                            <div class="row">
                                <asp:Label for="editPn" CssClass="col-12 text-left lbl_form" ID="Label8" runat="server" Text="<%$ Resources:Language, lbl_rg_pn %>" ForeColor="Black"></asp:Label>
                                <div class="col-12 text-left">
                                    <asp:TextBox ID="editPn" runat="server" CssClass="form-control form-control-sm"></asp:TextBox>
                                </div>
                            </div>
                        <div class="modal-footer">
                            <asp:Button ID="btnMdlEditar" CssClass="btn btn-info btn-sm" runat="server" Text="<%$ Resources:Language, btn_Autorizar %>" OnClick="btnMdlEditar_OnClick"/>
                            <asp:Button ID="btnCancelarEditar" CssClass="btn btn-danger btn-sm" runat="server" Text="<%$ Resources:Language, btn_Cancelar %>" OnClick="btnCancelar_OnClick" />
                        </div>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>

 

Modal Delete Code

<div class="modal fade" id="mdlPartDelete" role="dialog" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog">
            <asp:UpdatePanel ID="UpdatePanel3" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                <ContentTemplate>
                    <div class="modal-content">
                        <div class="modal-header">
                        </div>
                       
                        <div class="modal-footer">
                            <asp:Button ID="btnMdlDelete" CssClass="btn btn-info btn-sm" runat="server" Text="<%$ Resources:Language, btn_Autorizar %>" OnClick="btnMdlDelete_Click" CommandName="MdlDelete" CommandArgument='<%# Eval("IdIdPartNumber") %>'/>
                            <asp:Button ID="btnCancelarDelete" CssClass="btn btn-danger btn-sm" runat="server" Text="<%$ Resources:Language, btn_Cancelar %>" OnClick="btnMdlDelete_Click" CommandName="MdlDelCancel"/>
                        </div>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>

 

Behind code

protected void rgPart_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            try
            {
                this.rgPart.DataSource = CDatos.SP_PeticionesAlmacen.SP_ObtenerPartNumbers();
                this.upPart.Update();
            }
            catch (Exception ex) { this.ShowMessage("Err. load grid rgPart." + ex.Message, "danger"); }
        }

 

 protected void btnCancelar_OnClick(object sender, EventArgs e)
        {

            this.CloseModal("mdlPartInsert");

            this.CloseModal("mdlPartEdit");
        }

 

protected void ItemCommand(object source, GridCommandEventArgs e)
        {
            try
            {
                int IdPartNumber;
                int.TryParse(e.CommandArgument.ToString(), out IdPartNumber);

                if (e.CommandName.Equals("Delete"))
                {
                    this.OpenModal("mdlPartDelete");
                    txtId.Text = IdPartNumber.ToString();
                }
                if (e.CommandName.Equals("InitInsert"))
                {
                    this.OpenModal("mdlPartInsert");
                }
                else if (e.CommandName.Equals("Update"))
                {
                    int.TryParse(((GridEditFormItem)e.Item).GetDataKeyValue("IdPartNumber").ToString(), out IdPartNumber);
                    this.rgNotas_ItemUpdated(IdPartNumber, (GridEditFormItem)e.Item);
                }
                else if (e.CommandName.Equals("Editar"))
                {
                    this.OpenModal("mdlPartEdit");
                    txtId.Text = IdPartNumber.ToString();
                    int.TryParse(((GridEditFormItem)e.Item).GetDataKeyValue("IdPartNumber").ToString(), out IdPartNumber);
                }
                else if (e.CommandName.Equals("MdlDelete"))
                {
                    this.eliminaPart(IdPartNumber);
                }
            }
            catch (Exception ex) { this.ShowMessage("Err. grid rgPart." + ex.Message, "danger"); }
        }

 

protected void btnInsertar_Click(object sender, EventArgs e)
        {
            this.OpenModal("mdlPartInsert");
        }

 

protected void btnAutorizar_OnClick(object sender, EventArgs e)
        {
            var part = txtPart.Text;
            try
            {
                var id = CDatos.DHerramientas.InsertPart(txtpart.Text);
                this.upDatos.Update();
                this.ShowMessage(Resources.Language.mess_insert, "success");
            }
            catch (Exception ex){this.ShowMessage(ex.Message, "danger"); }
            this.CloseModal("mdlPartInsert");
        }

 

protected void btnEliminar_Click(object sender, ImageClickEventArgs e)
        {
            this.OpenModal("mdlPartDelete");
        }

        protected void btnMdlDelete_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            switch (btn.CommandName)
            {
                case "MdlDelete":
                    eliminaPart(int.Parse(txtId.Text));
                    break;
                case "MdlDelCancel":
                    this.CloseModal("mdlPartDelete");
                    break;
            }
        }

 

private void eliminaPart(int IdPartNumber)
        {
            try
            {
                Boolean eliminar = CDatos.DHerramientas.DeletePart(IdPartNumber);
                rgPart.Rebind();
                this.upDatos.Update();
                this.ShowMessage(Resources.Language.mess_delete, "success");
            }
            catch (Exception ex) { this.ShowMessage(ex.Message, "danger"); }
            this.CloseModal("mdlPartDelete");
        }

 

private void rgPart_ItemUpdated(int IdPartNumber, GridEditFormItem editar)
        {
            var part = ((TextBox)editar["Part"].Controls[0]).Text;

try
            {
                var id = CDatos.DPartNumbers.UpdatePartNumbers(IdPartNumber, part);
                this.upDatos.Update();
                this.ShowMessage(Resources.Language.mess_update, "success");
            }
            catch (Exception ex) { this.ShowMessage(ex.Message, "danger"); }
        }

 

Modal Edit method is not implemented yet, just the Edit method from the Grid, what I need to do is to get the data from the grid into the textbox of the modal

Attila Antal
Telerik team
 answered on 18 Feb 2020
2 answers
2.3K+ views

Hello

 

I have a radgrid which allows the user to select a row with 2 methods: by clicking on the row and by clicking a button in the row, so the user can edit or delete the information in those rows and to display information in another radgrid related to the row selected (Radgrid1 = Requests, Radgrid2 = Details, so if Request #2 is selected, the details of that requests are displayed in the other grid)

 

I have no issues if the user uses the "click on the row method", but if the user tries using the button it shows me the error:

     "Unable to cast object of type 'Telerik.Web.UI.GridDataItem' to type 'Telerik.Web.UI.GridEditFormItem'"

 

The button method by itself works, it still updates, deletes and populates the second grid in a correct way, but if the user edits, it doesnt show the results until the radgrid is refreshed or until the row is selected again. I need help to fix that, even if it still works in some way.

 

RadGrid1

<asp:UpdatePanel ID="upPeticiones" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                    <ContentTemplate>
                        <telerik:RadGrid ID="rgPeticiones" runat="server" GroupingSettings-CaseSensitive="false"  AllowPaging="True" RenderMode="Lightweight"
                            AllowSorting="true" AllowFilteringByColumn="True"  PageSize="5 " OnNeedDataSource="rgPeticiones_NeedDataSource" OnItemCommand="ItemCommand" OnItemDataBound="rgPeticiones_ItemDataBound" OnSelectedIndexChanged="rgPeticiones_SelectedIndexChanged"
                                CssClass="RadGrid_Silk" EnableHeaderContextMenu="true" GridLines="Horizontal" Width="100%" AllowAutomaticDeletes="True" AllowAutomaticInserts="False" AllowAutomaticUpdates="False" AllowMultiRowSelection="false" MasterTableView-AllowSorting="false">
                            <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true">
                            </ClientSettings>
                            <HeaderContextMenu Enabled="false"></HeaderContextMenu>
                            <MasterTableView AutoGenerateColumns="false" DataKeyNames="Folio" ItemStyle-HorizontalAlign="Center" AlternatingItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" NoMasterRecordsText="<%$ Resources:Language, lbl_tablaVacia %>" CommandItemDisplay="Top"  EditMode="PopUp" EditFormSettings-CaptionFormatString="<%$ Resources:Language, lbl_rg_termino %>">
                                <CommandItemSettings ShowAddNewRecordButton="false" AddNewRecordText="" RefreshText="<%$ Resources:Language, lbl_actualizar %>"/>
                                <Columns>
                                    <telerik:GridBoundColumn DataField="Folio" HeaderText="<%$ Resources:Language, lbl_rg_folio %>" Display="true" ReadOnly="true" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo" ShowFilterIcon="false" FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" DataType="System.String" AllowSorting="false"></telerik:GridBoundColumn>

                                    .....

 

                                    (Button for selection)
                                    <telerik:GridTemplateColumn DataField="" HeaderText=""  HeaderStyle-Width="3%"  AllowFiltering="false" UniqueName="Detalles">
                                        <ItemTemplate>
                                            <asp:ImageButton  ID="imgDetalle" runat="server" CausesValidation="False" CommandArgument='<%# Eval("Folio") %>' CommandName="Detalle" ImageUrl="~/images/detail.png" ItemStyle-Wrap="True"  ToolTip="<%$ Resources:Language, lbl_rg_detalle %>" OnClick="imgDetalle_Click" OnClientClick="deselectrows();"/>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" Width="3%" />
                                    </telerik:GridTemplateColumn>

                                    
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>
                    </ContentTemplate>
                </asp:UpdatePanel>

 

RadGrid2

 <asp:UpdatePanel ID="upNota" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                    <ContentTemplate>
                        <telerik:RadGrid ID="rgNota" runat="server" GroupingSettings-CaseSensitive="false"  AllowPaging="True" RenderMode="Lightweight"
                            AllowSorting="true" AllowFilteringByColumn="True"  PageSize="10" OnNeedDataSource="rgNota_NeedDataSource"  OnItemDataBound="rgNota_ItemDataBound"
                                CssClass="RadGrid_Silk" EnableHeaderContextMenu="false" GridLines="Horizontal" Width="100%"  MasterTableView-EditFormSettings-FormTableButtonRowStyle-HorizontalAlign="Right">
                            <HeaderContextMenu Enabled="false"></HeaderContextMenu>
                            <MasterTableView AutoGenerateColumns="false" DataKeyNames="Folio" ItemStyle-HorizontalAlign="Center" AlternatingItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" NoMasterRecordsText="<%$ Resources:Language, lbl_tablaVacia %>" CommandItemDisplay="Top">
                                <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false"/>
                                <EditFormSettings  FormTableStyle-HorizontalAlign="Right" FormTableButtonRowStyle-HorizontalAlign="Right" >
                                </EditFormSettings>
                                <Columns>
                                    
                                    <telerik:GridBoundColumn DataField="Folio" HeaderText="<%$ Resources:Language, lbl_rg_folio %>" Display="false" ReadOnly="true" AutoPostBackOnFilter="true" AllowFiltering="false" CurrentFilterFunction="EqualTo" ShowFilterIcon="false" FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" DataType="System.String">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Nota" HeaderText="<%$ Resources:Language, lbl_rg_nota %>" Display="true" AllowFiltering="false" ReadOnly="true" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
                                    
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>
                    </ContentTemplate>
                </asp:UpdatePanel>

 

protected void ItemCommand(object source, GridCommandEventArgs e)
        {
            try
            {
                int Folio;
                int.TryParse(e.CommandArgument.ToString(), out Folio);

                if (e.CommandName.Equals("Delete")) this.eliminaPeticion(Folio);
                else if (e.CommandName.Equals("Update"))
                {
                    int.TryParse(((GridEditFormItem)e.Item).GetDataKeyValue("Folio").ToString(), out Folio);
                    this.rgPeticiones_ItemUpdated(Folio, (GridEditFormItem)e.Item);
                }
                else if (e.CommandName.Equals("Detalle"))
                {
                    int.TryParse(((GridEditFormItem)e.Item).GetDataKeyValue("Folio").ToString(), out Folio); *Here is where I get the Error Message
                    this.rgPeticiones_ItemUpdated(Folio, (GridEditFormItem)e.Item);
                }
            }
            catch (Exception ex) { this.ShowMessage("Err. grid rgPeticiones." + ex.Message, "danger"); }
        }

 

I have another error showing, this time in the NeedDataSource when the user tries to update the second RadGrid with the button method

"Index was out of range. Must be non-negative and less than the size of the collection parameter name:index"

 

protected void rgNota_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            try
            {
                Telerik.Web.UI.GridDataItem item = (Telerik.Web.UI.GridDataItem)rgPeticiones.SelectedItems[0]; *Here is where I get the second error
                foreach (Telerik.Web.UI.GridDataItem items in rgPeticiones.SelectedItems)
                {
                    var Folio = items["Folio"].Text;
                    int FolioInt = int.Parse(Folio.ToString());
                    try
                    {
                        rgDetalles.DataSource = CDatos.SP_PeticionesAlmacen.SP_ObtenerDetalle(FolioInt);
                        upDetalles.Update();
                    }
                    catch (Exception ex) { this.ShowMessage("Err. load grid rgDetalles." + ex.Message, "danger"); }
                }
            }
            catch (Exception ex) { this.ShowMessage("Err. load grid rgDetalles." + ex.Message, "danger"); }
        }

 

The method works perfectly if the "Click on row" method is used

 

Would be possible to have a "false button"? An image in the radgrid for the user just to click, selecting the row? I have tried with a "telerik:GridImageColumn" in my radgrid, it display the image but doesnt select the row if its clicked

Attila Antal
Telerik team
 answered on 18 Feb 2020
2 answers
334 views
Hello everyone, I'm encountering some issues when I tried to export excel from Grid. I added three GridTemplateColumn which contained buttons in those template columns. The Export To Excel button is added with Telerik RadButton separately because of user requirement. When I clicked the export to excel button, the button inside of the GridTemplateColumn becomes null value. Can someone help me how to solve it?

The following code is my Telerik Grid
<telerik:RadGrid ID="RadGridSalesOrder" runat="server" Width="100%" Height="600px"
                        OnNeedDataSource="RadGridSalesOrder_NeedDataSource" OnItemDataBound="RadGridSalesOrder_ItemDataBound"
                        OnBiffExporting="RadGridSalesOrder_BiffExporting" OnPreRender="RadGridSalesOrder_PreRender"
                        GridLines="None" AllowSorting="false" ShowGroupPanel="false" ShowFooter="false"
                        CellSpacing="0" AutoGenerateColumns="False" RenderMode="Auto"
                        ClientSettings-Selecting-AllowRowSelect="true" FooterStyle-Height="20px"
                        EnableHeaderContextFilterMenu="True" AllowPaging="true" PageSize="2000" AllowMultiRowSelection="false"
                        MasterTableView-EnableHeaderContextFilterMenu="true" EnableLinqExpressions="False" EnableHeaderContextMenu="True">
                        <ClientSettings AllowRowsDragDrop="false" AllowColumnsReorder="true" Resizing-AllowColumnResize="true" ReorderColumnsOnClient="true">
                            <ClientEvents OnCommand="GridCommand" />
                            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="false" ScrollHeight="250"></Scrolling>
                            <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                        </ClientSettings>
                        <ExportSettings FileName="SalesOrderApprovalList" IgnorePaging="true">
                            <Excel Format="Biff" />
                        </ExportSettings>
                        <GroupingSettings CaseSensitive="false" />
                        <MasterTableView DataKeyNames="OrderID,BranchID,CustomerID,CustomerInfo,OrderDate,DeliveryDate,Address"
                            AllowMultiColumnSorting="True" AllowPaging="true"
                            ClientDataKeyNames="OrderID,BranchID,CustomerID,CustomerInfo,Address,SalesPersonID,Remark,OrderDate,DeliveryDate"
                             PagerStyle-PageSizes="500,1000,1500,2000" AllowFilteringByColumn="true" AutoGenerateColumns="false" ShowHeadersWhenNoRecords="true">
                            <Columns>
                                <telerik:GridButtonColumn UniqueName="Update" ButtonType="ImageButton" ImageUrl="../images/icons8-window-settings-20.png" HeaderText="Open" Text="Open" CommandName="Open">
                                    <HeaderStyle Width="40px" />
                                    <ItemStyle Width="40px" HorizontalAlign="Center" />
                                </telerik:GridButtonColumn>
 
                                <telerik:GridTemplateColumn HeaderText="No" UniqueName="RowNumber" AllowFiltering="false">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="lblRowNumber" Width="50px" Text='<%# Container.DataSetIndex+1 %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="30px" />
                                    <HeaderStyle Width="30px" />
                                </telerik:GridTemplateColumn>
 
                                 <telerik:GridTemplateColumn UniqueName="Approve" HeaderStyle-Width="90px" ShowFilterIcon="false" AllowFiltering="false">
                                    <ItemTemplate>
                                        <div style="text-align: center;">
                                            <telerik:RadButton ID="btnApprove" runat="server" AutoPostBack="true" Text="Approve" OnClientClicking="OnClientClicking" OnClick="btnApprove_Click">
                                            </telerik:RadButton>
                                        </div>
                                    </ItemTemplate>
                                    <ItemStyle Width="90px" />
                                </telerik:GridTemplateColumn>
 
                                <telerik:GridTemplateColumn UniqueName="BatchExpiry" AllowFiltering="false">
                                        <ItemTemplate>
                                       <%-- <asp:LinkButton ID="btnAddBatch" Text="Add Batch" runat="server">
                                        </asp:LinkButton>--%>
                                         <%-- <telerik:RadLinkButton ID="btnAddBatch" runat="server" Text="Add Batch">
                                               
                                          </telerik:RadLinkButton>--%>
                                          <telerik:RadButton ID="btnAddBatch" runat="server" Text="Add Batch" AutoPostBack="true" OnClick="btnAddBatch_Click"></telerik:RadButton>
                                    </ItemTemplate>
                                    <ItemStyle Width="45px" />
                                    <HeaderStyle Width="45px" />
                                </telerik:GridTemplateColumn>
 
                                <telerik:GridBoundColumn DataField="IsReserved" AllowFiltering="true" HeaderText="Is Reserved" UniqueName="IsReserved"
                                    ShowFilterIcon="false" FilterControlWidth="75px"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="90px" />
                                    <ItemStyle Width="90px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn DataField="OrderID" AllowFiltering="true" HeaderText="Order ID" UniqueName="OrderID"
                                    ShowFilterIcon="false" FilterControlWidth="100px"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="110px" />
                                    <ItemStyle Width="110px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn DataField="BranchID" AllowFiltering="false" HeaderText="Branch ID" UniqueName="BranchID"
                                    ShowFilterIcon="false" FilterControlWidth="100px" Visible="false"
                                    AutoPostBackOnFilter="false" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="110px" />
                                    <ItemStyle Width="110px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn DataField="SalesPersonName" HeaderText="Sales Person" UniqueName="SalesPersonName"
                                    ShowFilterIcon="false" FilterControlWidth="105px" AllowFiltering="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="120px" />
                                    <ItemStyle Width="120px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="CustomerID" AllowFiltering="true" HeaderText="Customer ID" Visible="true" UniqueName="CustomerID"
                                    ShowFilterIcon="false" FilterControlWidth="110px"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="130px" />
                                    <ItemStyle Width="130px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="CustomerName" HeaderText="Name" UniqueName="CustomerName"
                                    ShowFilterIcon="false" FilterControlWidth="150px" AllowFiltering="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="189px" />
                                    <ItemStyle Width="189px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="CustomerInfo" HeaderText="Customer Info" UniqueName="CustomerInfo"
                                    ShowFilterIcon="false" FilterControlWidth="150px" AllowFiltering="false" Visible="false"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="189px" />
                                    <ItemStyle Width="189px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Address" HeaderText="Address" UniqueName="Address"
                                    ShowFilterIcon="false" FilterControlWidth="170px" AllowFiltering="true" Visible="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="189px" />
                                    <ItemStyle Width="189px" />
                                </telerik:GridBoundColumn>
 
                                 <telerik:GridBoundColumn DataField="Township" HeaderText="Township" UniqueName="Township"
                                    ShowFilterIcon="false" FilterControlWidth="120px" AllowFiltering="true" Visible="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                    <HeaderStyle Width="150px" />
                                    <ItemStyle Width="150px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn DataField="OrderDate" AllowFiltering="false" HeaderText="Order Date" UniqueName="OrderDate"
                                    ShowFilterIcon="false" FilterControlWidth="110px"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="85px" />
                                    <ItemStyle Width="85px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn DataField="DeliveryDate" AllowFiltering="false" HeaderText="Delivery Date" UniqueName="DeliveryDate"
                                    ShowFilterIcon="false" FilterControlWidth="110px"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="85px" />
                                    <ItemStyle Width="85px" />
                                </telerik:GridBoundColumn>
 
 
                                <telerik:GridBoundColumn DataField="DeliveryVan" AllowFiltering="true" HeaderText="Delivery Van" UniqueName="DeliveryVan"
                                    ShowFilterIcon="false" FilterControlWidth="100px"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="110px" />
                                    <ItemStyle Width="110px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn UniqueName="SalesPersonID" DataField="SalesPersonID" AllowFiltering="true" ShowFilterIcon="false" FilterControlWidth="100px"
                                    HeaderText="SalesPerson ID" Visible="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true">
                                </telerik:GridBoundColumn>
 
                                 <telerik:GridBoundColumn DataField="Remark" HeaderText="Remark" UniqueName="Remark"
                                    ShowFilterIcon="false" FilterControlWidth="84px" AllowFiltering="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="104px" />
                                    <ItemStyle Width="104px" />
                                </telerik:GridBoundColumn>
 
                                 <telerik:GridBoundColumn DataField="SyncDateTime" HeaderText="Sync Date" UniqueName="SyncDateTime"
                                    ShowFilterIcon="false" FilterControlWidth="84px" AllowFiltering="false"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="85px" />
                                    <ItemStyle Width="85px" />
                                </telerik:GridBoundColumn>
 
                                 <telerik:GridBoundColumn DataField="ExportDateTime" HeaderText="Export Date" UniqueName="ExportDateTime"
                                    ShowFilterIcon="false" FilterControlWidth="84px" AllowFiltering="false"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="85px" />
                                    <ItemStyle Width="85px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn DataField="ExportStatus" HeaderText="Export Status" UniqueName="ExportStatus"
                                    ShowFilterIcon="false" FilterControlWidth="75px" AllowFiltering="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="85px" />
                                    <ItemStyle Width="85px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn DataField="ExportRemark" HeaderText="Export Remark" UniqueName="ExportRemark"
                                    ShowFilterIcon="false" FilterControlWidth="84px" AllowFiltering="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="104px" />
                                    <ItemStyle Width="104px" />
                                </telerik:GridBoundColumn>
 
                               <telerik:GridBoundColumn DataField="ApprovedBy" HeaderText="Approved By" UniqueName="ApprovedBy"
                                    ShowFilterIcon="false" FilterControlWidth="84px" AllowFiltering="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="104px" />
                                    <ItemStyle Width="104px" />
                                </telerik:GridBoundColumn>
 
                                 <telerik:GridBoundColumn DataField="ApprovedDate" HeaderText="Approved Date" UniqueName="ApprovedDate"
                                    ShowFilterIcon="false" FilterControlWidth="84px" AllowFiltering="false"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="85px" />
                                    <ItemStyle Width="85px" />
                                </telerik:GridBoundColumn>
 
                                <telerik:GridBoundColumn DataField="RejectedBy" HeaderText="Rejected By" UniqueName="RejectedBy"
                                    ShowFilterIcon="false" FilterControlWidth="84px" AllowFiltering="true"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="104px" />
                                    <ItemStyle Width="104px" />
                                </telerik:GridBoundColumn>
 
                                 <telerik:GridBoundColumn DataField="RejectedDate" HeaderText="Rejected Date" UniqueName="RejectedDate"
                                    ShowFilterIcon="false" FilterControlWidth="84px" AllowFiltering="false"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" >
                                    <HeaderStyle Width="85px" />
                                    <ItemStyle Width="85px" />
                                </telerik:GridBoundColumn>
 
 
 
                                 
 
                                <%--<telerik:GridBoundColumn DataField="DeliveryStatus" HeaderText="Status" UniqueName="Status" Visible="false"
                                    ShowFilterIcon="false" FilterControlWidth="170px" AllowFiltering="true" AutoPostBackOnFilter="true">
                                    <HeaderStyle Width="50px" />
                                    <ItemStyle Width="50px" />
                                </telerik:GridBoundColumn>--%>
                            </Columns>
                            <PagerStyle AlwaysVisible="True"></PagerStyle>
                            <GroupFooterTemplate>
                            </GroupFooterTemplate>
                        </MasterTableView>
                        <PagerStyle UseRouting="True" Mode="NumericPages" ShowPagerText="False" />
 
                    </telerik:RadGrid>

 

Nelson
Top achievements
Rank 1
 answered on 18 Feb 2020
1 answer
165 views

I am trying to write a function that if a condition exists,  it cancels the selection and provides an alert("something is wrong") to the user.  This works; however, when the selection is cleared from the destination box, it no longer appears in the source box.

Here is html for Listbox:

 <telerik:RadListBox RenderMode="Lightweight" runat="server" ID="boxSource" Height="350px" Width="250px"
                                    AllowReorder="false"
                                    AllowTransfer="true"
                                    AllowTransferDuplicates="false"
                                    SelectionMode="Multiple"
                                    TransferMode="Move"
                                    TransferToID="boxDestination">
                                    <HeaderTemplate>
                                        Available Fields
                                    </HeaderTemplate>
                                </telerik:RadListBox>
                                <%-- Selected Fields --%>
                                <telerik:RadListBox RenderMode="Lightweight" runat="server" ID="boxDestination" Height="350px" Width="250px"
                                    SelectionMode="Multiple"
                                    AllowReorder="true">
                                    <HeaderTemplate>
                                        Zone Fields
                                    </HeaderTemplate>
                                </telerik:RadListBox>

 

Here is jQuery:

            var zoneNo = $("table.template td.active").attr("data-zone");

            var listBox = $find("<%= boxDestination.ClientID %>");
            //get current selected items
            var items = listBox.get_items(); 
            
            //store
            if (items.get_count() > 0) {
                if(zoneNo == undefined )
                {
                    items.clear();
                    return alert("Please select a zone");
                }
                let itemsCopy = Object.assign({}, items);
                $.data(listBox, zoneNo, itemsCopy);
            }

Eric R | Senior Technical Support Engineer
Telerik team
 answered on 17 Feb 2020
1 answer
212 views

Hi,

Spreadsheet is working fine on our evaluation server, but not is production server.

I think that it might be missing a dll file. What dll files are needed?

Br. Mikko

 

Peter Milchev
Telerik team
 answered on 17 Feb 2020
2 answers
165 views

I would like to know how to get the count of items of the list when the user types in something.

For instances, let's say that the user starts typing the "X" letter but my query doesn't returns any word with "X", so the count of items would be zero.

In this case I could display a warning message like "There is no one possible choice that matches your typing".

Any idea?

Yan Moura
Top achievements
Rank 1
Veteran
Iron
 answered on 14 Feb 2020
3 answers
705 views

Hello,

I have a RadGrid for which I have enabled exporting to Excel using the XSLX format. The export works very well except the export removes hyperlinks from the grid and replaces them with plain text. I have a requirement to include in the resulting XSLX file the hyperlink that appears in the grid in a GridHyperlinkColumn. I have tried altering the ExportOnlyData value in the grid's export settings, but that causes the data in the GridHyperlinkColumn to not appear at all. Here is a simplified grid. Thank you for your advice on whether XSLX exports can include hyperlinks.

  <telerik:RadGrid ID="rgInstSearchResults" runat="server" RenderMode="Lightweight"
        DataSourceID="odsInstSearch" AutoGenerateColumns="false" Skin="Bootstrap"
        ShowStatusBar="true" AllowMultiRowSelection="true" Width="95%" GridLines="Both"
        AllowFilteringByColumn="false">
        <ClientSettings>
            <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true" />
        </ClientSettings>
        <ExportSettings ExportOnlyData="true" OpenInNewWindow="true" FileName="InstitutionSearchResults" IgnorePaging="true">
            <Excel DefaultCellAlignment="Left" Format="Xlsx" />
            <Word Format="Html" />
        </ExportSettings>
        <MasterTableView Name="mtvInstSearchResults" DataSourceID="odsInstSearch"
            DataKeyNames="InstitutionID" CommandItemDisplay="Top" AllowPaging="true"
            AllowSorting="true" PageSize="50" AllowMultiColumnSorting="true" AllowAutomaticDeletes="true"
            ShowFooter="True" AllowAutomaticInserts="False" AllowAutomaticUpdates="False">
            <CommandItemStyle BackColor="#dae0ed" Font-Bold="true" HorizontalAlign="Right" />
            <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="true"
                ShowExportToWordButton="true" />
            <PagerStyle AlwaysVisible="true" PageSizes="25,50,100,500" />
            <Columns>
                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" Reorderable="False" Exportable="false" />
                <telerik:GridHyperLinkColumn UniqueName="InstitutionID" HeaderText="ID"
                    DataNavigateUrlFields="InstitutionID" Reorderable="False"
                    DataNavigateUrlFormatString="ViewInstitution.aspx?InstitutionID={0}"
                    DataTextField="InstitutionID" Target="_blank" />
</Columns>
  </MasterTableView>
    </telerik:RadGrid>

 

Beth
Top achievements
Rank 1
 answered on 14 Feb 2020
0 answers
171 views

I am trying to post an array from jQuery on an .aspx page to a method in the codebehind using Telerik AjaxManager. The problem I am having is converting the string to a list or even an array using C#. The string (after using Json.stringify in jQuery) looks like this:

string zoneString = "[[1,[["Ticket Core.AFE"],["Ticket Core.CompanyName"]]],[2,[["Ticket Core.CompanyCity"],["Ticket Core.CompanyState"]]]]"

I tried to deserialize like this:
List<ZoneInfo> zones = JsonConvert.DeserializeObject<List<ZoneInfo>>(zonesString);

But that produced an error.

Here is my client-side code:
var zones = [];

for (var i = 1; i <= zoneCount; i++)

{

var o = $.data(listBox, i.toString());

if(o != undefined){var items = [];var a = o._array;

//pull the key/value

for (x = 0; x < a.length; x++)

{

var item = a[x];

var value = item.get_value();

value items.push([value]);

}

zones.push([i, items]);

}}

jsonZones = JSON.stringify(zones);

var ajaxManager = $find("<%= ((RadAjaxManager)this.Page.Master.FindControl("RadAjaxManager1")).ClientID %>"); ajaxManager.ajaxRequest('CREATEREPORT|' + jsonZones + '|' + tid);

 

Here is my server-side code:
protected void AjaxMgr_AjaxRequest(object sender, AjaxRequestEventArgs e)

{

string[] args = e.Argument.Split('|');

string sCommand = args[0];

switch (sCommand.ToUpper())

{

case "CREATEREPORT":string zonesString = args[1];

List<ZoneInfo> zones = JsonConvert.DeserializeObject<List<ZoneInfo>>(zonesString);

var template = args[2];

string[] zone = new string[zones.Count];break;

}

InitializeWizard();}

Brad
Top achievements
Rank 1
 asked on 14 Feb 2020
3 answers
610 views

I am implementing a RadGrid with batch mode editing using clientside binding with a RadClientDataSource.   I am finding that calling .hasChanges() results in records flagged for Delete to not actually get deleted when .saveChanges() executes.

 

This is my setup: 

I created my own button for saving,  as such:

<CommandItemTemplate>
             <telerik:RadButton  ID="RadButtonSave" runat="server" Text="Save" CssClass="GoButton" AutoPostBack="false" OnClientClicked="function(){ saveChanges();}" >
            </telerik:RadButton>
</CommandItemTemplate>

 

Which calls the following javascript function:

 

function saveChanges() {
  var grid = $find("<%= RadGrid1.ClientID %>");
  //var isDirty = grid.get_batchEditingManager().hasChanges(grid.get_masterTableView());
  grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());
}

If I make changes to grid data and click the Save button the webservices for the insert, update, delete are being called.

HOWEVER, if I uncomment the "var isDirty...." line in the above .saveChanges() function that calls .hasChanges(),  then the Deletes will no longer save.   The web service for deletes simply does not get called. Inserts and update still work correctly.   If i comment out that line, then the deletes work again.

 

I found the same behaviour on a LiveDemo example that checks .hasChanges().

https://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-data-source-binding/defaultcs.aspx

Steps to reproduce:

- Make any change to the first record, such as modifying the Contact Name.

- On the second record, Click the "x" under the DELETE column to mark it for delete.

- Click any column heading to sort.  (This calls a UserAction event handler that calls .hasChanges())

- Choose to Cancel at the popup prompt.

- Click "Save changes".

- Monitor the browser console, you will find that webservice UpdateCustomers is called,  but DeleteCustomers is not.

 

Please confirm whether this is a bug and if there is a workaround.

 

Attila Antal
Telerik team
 answered on 13 Feb 2020
3 answers
170 views

It seems that Column names (title, start time, end time,..) are not translated via dictionary (RadGantt.resx)

Is there a way to change column names?

 

 

Peter Milchev
Telerik team
 answered on 13 Feb 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?