client side (insertItem)

4 posts, 0 answers
  1. Michael Pullella
    Michael Pullella avatar
    26 posts
    Member since:
    Nov 2009

    Posted 01 Apr 2010 Link to this post

    Hi...

    I have a listview on a page, I am trying to add an item via javascript with insertItem().  What params am I supposed to give to the method in order to add an item?

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
            <Scripts> 
                <%--Needed for JavaScript IntelliSense in VS2010--%> 
                <%--For VS2008 replace RadScriptManager with ScriptManager--%> 
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> 
            </Scripts> 
        </telerik:RadScriptManager> 
        <script type="text/javascript">  
            //Put your Java Script code here.  
        </script> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        </telerik:RadAjaxManager> 
       
        <telerik:RadSkinManager ID="RadSkinManager1" Runat="server" Skin="Outlook">  
        </telerik:RadSkinManager> 
        <div> 
     
            <telerik:RadListView ID="RadListView1" runat="server"   
                DataSourceID="AccessDataSource1" Skin="Office2007">  
                <AlternatingItemTemplate> 
                    <div class="rlvA">  
                        <img src="images/book.png" />&nbsp;<asp:Label ID="Field1Label" runat="server" Text='<%# Eval("Field1") %>' /> 
                    </div> 
                </AlternatingItemTemplate> 
                <ItemTemplate> 
                    <div class="rlvI">  
                        <img src="images/book.png" />&nbsp;<asp:Label ID="Field1Label" runat="server" Text='<%# Eval("Field1") %>' /> 
                    </div> 
                </ItemTemplate> 
                <EmptyDataTemplate> 
                    <div class="RadListView RadListView_Office2007">  
                        <div class="rlvEmpty">  
                            There are no items to be displayed.</div> 
                    </div> 
                </EmptyDataTemplate> 
                <LayoutTemplate> 
                    <div class="RadListView RadListView_Office2007">  
                        <div ID="itemPlaceholder" runat="server">  
                        </div> 
                    </div> 
                </LayoutTemplate> 
                <SelectedItemTemplate> 
                    <div class="rlvISel">  
                        &nbsp;<asp:Label ID="Field1Label" runat="server" Text='<%# Eval("Field1") %>' /> 
                    </div> 
                </SelectedItemTemplate> 
            </telerik:RadListView> 
            <asp:AccessDataSource ID="AccessDataSource1" runat="server"   
                DataFile="~/App_Data/Database.mdb" SelectCommand="SELECT [Field1] FROM [NAMES]">  
            </asp:AccessDataSource> 
            <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="InsertNewItem()" /> 
              
            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
            <script type="text/javascript">  
                function InsertNewItem() {  
                    alert("What params am I supposed to pass in order to have the listview insert a row for me?");  
                    var listView = $find("<%= RadListView1.ClientID %>");  
                    listView.insertItem();  
                }  
            </script> 
            </telerik:RadCodeBlock> 
        </div> 
        </form> 
    </body> 
    </html> 
     
  2. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 01 Apr 2010 Link to this post

    Hello Michael,

    insertItem client-side method is meant to trigger PerformInsertCommand, thus it is doing the same thing as clicking on insert button in the insert form. Therefore in order to use it you should show the InsertItem first, then after user enters some data you can call insertItem() method to submit the form to the server.

    I hope this helps.
    Rosen
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Phani
    Phani avatar
    10 posts
    Member since:
    Mar 2015

    Posted 24 Jul 2015 in reply to Rosen Link to this post

    How to display InsertItem using Javascript? Please help.

     

    Thanks,

    Phani

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 28 Jul 2015 Link to this post

    Hello Phani,

    In orders to achieve the required functionality you can use the fireCommand () method and fire InitInsert command as described below:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/listview/client-side-programming/radlistview/methods/firecommand


    Regards,
    Maria Ilieva
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top