Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
140 views

 

I have a page with a command button and a Rad window that has a content template that contain a user control. The user control has a little JavaScript for custom validations. Everything works fine until I try to use an Ajax manager. When I hook the toolbar button to the Rad windows on the default page everything breaks. I have attached the code for what I am trying to do, if you disable the Ajax manager on the default page my little program works great, however if you enable and configure the Ajax and everything breaks. Currently the Ajax manager is enabled, try running it as it is and then disable Ajax and you will see what I mean.  The first time you click the  tool bar button it appears that  everything is fine, however  if you click cancel and then click the tool bar again the user control is rendered partly and is garbled. Additionally none of the JavaScript on the user control works.
This is not my entire project just a snipit there is a lot more going on and all the other Ajax works fine, I would like to use Ajax in this scenario to avoid post back on the tool bar button click that displays the rad window that has the user control to flow with therest of my project in terms of no post backs and everything else Ajaxified. Please see attached and help if you can. The data on the user control list box comes from the North wind data base Customers Company Name.  Thanks Ken G.

 

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<%@ Register Src="Controls/CreateMessageRadListBox.ascx" TagName="CreateMessageRadListBox" TagPrefix="uc" %>

<%@ Register Assembly="Telerik.Web.UI, Version=2009.3.1208.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!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>

</head>

<body>

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

    <telerik:RadToolBar ID="RadToolBar1" runat="server" OnButtonClick="RadToolBar1_ButtonClick" Width="100px">

        <Items>

            <telerik:RadToolBarButton runat="server" Text="UC RadListBox">

            </telerik:RadToolBarButton>

        </Items>

    </telerik:RadToolBar>

    <telerik:RadWindow ID="rwUserControlListBox" runat="server" Behaviors="Move" Height="630px" KeepInScreenBounds="True" Modal="true" Overlay="True" Skin="Office2007" Title="Create Message" Visible="false" VisibleOnPageLoad="true" VisibleStatusbar="false" Width="800px">

        <ContentTemplate>

            <uc:CreateMessageRadListBox ID="CreateMessageRadListBox" runat="server" OnCreatedMessage="ucCreateMessage_OnCreateMessage" OnCancel="ucCreateMessage_OnCancel" />

        </ContentTemplate>

    </telerik:RadWindow>

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

    </telerik:RadScriptManager>

    <br />

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

        <AjaxSettings>

            <telerik:AjaxSetting AjaxControlID="RadToolBar1">

                <UpdatedControls>

                    <telerik:AjaxUpdatedControl ControlID="rwUserControlListBox" />

                </UpdatedControls>

            </telerik:AjaxSetting>

        </AjaxSettings>

    </telerik:RadAjaxManager>

    </form>

</body>

</html>

 

Default.aspx.cs

using System;

using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page {

    protected void RadToolBar1_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e) {

        switch (e.Item.Text) {

            case "UC RadListBox":

                rwUserControlListBox.Visible = true;

                break;

        }

    }

    protected void ucCreateMessage_OnCreateMessage(object sender, EventArgs e) {

        rwUserControlListBox.Visible = false;

    }

    protected void ucCreateMessage_OnCancel(object sender, EventArgs e) {

        rwUserControlListBox.Visible = false;

    }

}

 

CreateMessageRadListBox.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CreateMessageRadListBox.ascx.cs" Inherits="Controls.CreateMessageRadListBox" %>

<%@ Register Assembly="Telerik.Web.UI, Version=2009.3.1208.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<body style="font-family: Calibri">

    <telerik:RadCodeBlock runat="server" ID="rcbjs">

        <script type="text/javascript">

            function checkForDuplicateSelection(sender, args) {

                var usedField = new Array();

                var radUpload = $find('<%= ruFileUpload.ClientID %>');

                var fileInputs = radUpload.getFileInputs();

                var duplicateFieldFlag = false;

                for (var i = 0; i < fileInputs.length; i++) {

                    var fileName = fileInputs[i].value.substring(fileInputs[i].value.lastIndexOf("\\") + 1, fileInputs[i].value.length);

                    for (var j = 0; j < usedField.length; j++) {

                        //If at least one duplicate field exists

                        //the emptyFieldFlag is being raised

                        if (fileName == usedField[j]) {

                            duplicateFieldFlag = true;

                            //The first invalid file input

                            //field receives focus

                            radUpload.clearFileInputAt(i);

                            fileInputs[i].focus();

                            break;

                        }

                    }

                    if (duplicateFieldFlag) {

                        args.IsValid = false;

                        return;

                    }

                    if (fileInputs[i].value.length != 0) {

                        usedField[usedField.length] = fileName;

                    }

                }

                args.IsValid = true;

            }

            function ValidationCriteria(source, args) {

                var listbox = $find('<%= rlbRecipients.ClientID %>');

                var check = 0;

                var items = listbox.get_items();

                for (var i = 0; i <= items.get_count() - 1; i++) {

                    var item = items.getItem(i);

                    if (item.get_checked()) {

                        check = 1;

                    }

                }

                if (check)

                    args.IsValid = true;

                else

                    args.IsValid = false;

            }

        </script>

    </telerik:RadCodeBlock>

    <table style="width: 100%">

        <tr valign="top">

            <td style="width: 220px;">

                <asp:Label ID="lblSentTo" runat="server" Font-Bold="True" Text="Send To :"></asp:Label>

                <asp:CustomValidator ID="cvReciepients" runat="server" ClientValidationFunction="ValidationCriteria" ErrorMessage="Reciepient Required" Font-Bold="True"></asp:CustomValidator>

                <telerik:RadListBox ID="rlbRecipients" runat="server" CheckBoxes="True" Width="100%" Height="570px" Skin="Office2007" DataKeyField="Company" DataSortField="Company" DataSourceID="SqlDataSource1" DataTextField="Company" Style="top: 0px; left: 0px">

                </telerik:RadListBox>

            </td>

            <td>

                <telerik:RadUpload ID="ruFileUpload" runat="server" Skin="Office2007" MaxFileInputsCount="5" BorderColor="White" BorderStyle="Solid" BorderWidth="1px">

                </telerik:RadUpload>

                <asp:CustomValidator ID="RadUploadDuplicateFieldsValidator" runat="server" ClientValidationFunction="checkForDuplicateSelection" Display="Dynamic" Font-Bold="True">

                 Duplicate File Removed! Only ONE Version of the Same File can be Attached!

                </asp:CustomValidator>

                <asp:Button ID="btnSendMessage" runat="server" OnClick="btnSendMessage_Click" Text="Send" />

                <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" CausesValidation="False" Height="26px" />

            </td>

        </tr>

    </table>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Northwind 20071SQLConnectionString %>" SelectCommand="SELECT [Company] FROM [Customers]"></asp:SqlDataSource>

    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">

        <AjaxSettings>

            <telerik:AjaxSetting AjaxControlID="chkPriorityMessage">

                <UpdatedControls>

                    <telerik:AjaxUpdatedControl ControlID="chkReadReceipt" />

                </UpdatedControls>

            </telerik:AjaxSetting>

        </AjaxSettings>

    </telerik:RadAjaxManagerProxy>

</body>

 

CreateMessageRadListBox.ascx.cs

using System;

using System.Web.UI;

 

 

namespace Controls {

    public partial class CreateMessageRadListBox : UserControl {

        public event EventHandler CreatedMessage;

        protected void OnCreatedMessage(EventArgs e) {

            if (CreatedMessage != null)

                CreatedMessage(this, e);

        }

        public event EventHandler Cancel;

        protected void OnCancel(EventArgs e) {

            if (Cancel != null)

                Cancel(this, e);

        }

        protected void btnSendMessage_Click(object sender, EventArgs e) {

            OnCreatedMessage(e);

        }

        protected void btnCancel_Click(object sender, EventArgs e) {

            OnCancel(e);

        }

    }

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Ken Gunderman
Top achievements
Rank 1
 answered on 23 Feb 2010
1 answer
92 views
Hello,
I'm trying to use your Ajax product with WCF Webservice, I've crated a webmethod :

    [OperationContract] 
        public RadComboBoxData GetGruppi(RadComboBoxContext context) 
        { 
            RadComboBoxData result = new RadComboBoxData(); 
 
            DataSet ds = dataAccess.GetListaGruppi(); 
 
            if (ds != null && ds.Tables[0].Rows.Count > 0) 
            { 
                List<RadComboBoxItemData> lst = new List<RadComboBoxItemData>(); 
 
                foreach (DataRow dr in ds.Tables[0].Rows) 
                { 
                    RadComboBoxItemData item = new RadComboBoxItemData(); 
 
                    item.Text = GetCheckedString(dr[2]); 
                   // item.Value = string.Format("{0}-{1}", Convert.ToInt32(dr[0]), Convert.ToInt32(dr[1])); 
                    item.Value = GetCheckedString(dr[0]); 
                    lst.Add(item); 
 
                } 
 
                
                result.Items = lst.ToArray(); 
            } 
 
 
            return result; 
        } 

and attached from ajax the WebServiceSetting :

 <WebServiceSettings Method="GetGruppi" Path="../WS/IFManagement.svc" /> 


but each time I try to use it I got this error :

Microsoft JScript runtime error: 'length' is null or not an object

The WS method is executed (I see the data in the result (via Vs2008) but when it should bind to the combobox got that exception...
any suggestion??
Thanks in advance
Paolo
Simon
Telerik team
 answered on 23 Feb 2010
4 answers
122 views
I am trying to dynamically load a usercontrol in the edit formtemplate of a grid, I only want a part of the template to change. I do that in the grids OnItemCreated event, So far so good. The usercontrol shows and I am able to enter the desired data.

Problem begins when I try to get hold of the usercontrol to actually save the data.

On clicking the update/save button of the formtemplate i want to connect to the usercontrol, get and save the content to the database.

I have tried numerous events and methods found in the forum, but i can't get hold of the control. I suspect this has to do with me adding the control dynamically, and closing the formtemplate results in a postback.

What is the best approach for this kind of scenario.

//Per Löfstedt
Jan Balas
Top achievements
Rank 1
 answered on 23 Feb 2010
5 answers
401 views
How can I configure my RadDatePicker to only allow me to pick the first of each month?
Chris Marisic
Top achievements
Rank 1
 answered on 23 Feb 2010
2 answers
200 views
Hi, I have the following radgrid:

 <telerik:RadAjaxPanel ID="MyPanel" runat="server">
        <telerik:RadInputManager ID="MyRadManager" runat="server">
                <telerik:RegExpTextBoxSetting BehaviorID="RegExpBehavior1" InitializeOnClient="false"
                    ErrorMessage="Invalid date format" InvalidCssClass="invalid"
                    ValidationExpression="((0[1-9]|1[012])[- /.](19|20)\d\d)">
                    <Validation IsRequired="true" />
                </telerik:RegExpTextBoxSetting>
            </telerik:RadInputManager>
            <telerik:RadGrid
                            ID="myGrid"
                            DataSourceID="MyDataSource"
                            runat="server"
                            AutoGenerateColumns="False"
                            GridLines="None"
                            AllowAutomaticDeletes="True"
                            AllowAutomaticInserts="True"
                            Skin="Outlook"
                            OnItemCreated="myGrid_ItemCreated"
                            OnItemCommand="myGrid_ItemCommand">
                    <HeaderContextMenu EnableTheming="True">
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                    </HeaderContextMenu>

                    <MasterTableView CommandItemDisplay="Top" DataKeyNames ="Id" DataSourceID="DegreesDataSource">
                       <CommandItemTemplate>
                                            
                                          <asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !myGrid.MasterTableView.IsItemInserted %>'>
                                                <%--<img style="border:0px" alt="" src="../../DataEditing/Img/AddRecord.gif" />--%> Add New Record</asp:LinkButton>
                                            <br />
                                        </CommandItemTemplate>
                    <RowIndicatorColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>

                    <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridBoundColumn DataField="Title" HeaderText="Title"
                                SortExpression="Title" >
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Area"
                                HeaderText="Subject Matter or Speciality Field" SortExpression="Area">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CompanyName" HeaderText="Company" SortExpression="CompanyName">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Year" HeaderText="Date" SortExpression="Year">
                            </telerik:GridBoundColumn>
                            <telerik:GridButtonColumn UniqueName="Delete" ButtonType="LinkButton" CommandName="Delete" Text="Remove"></telerik:GridButtonColumn>
                        </Columns>
                         <EditFormSettings EditFormType="Template">
                                            <EditColumn UniqueName="EditCommandColumn1">
                                            </EditColumn>
                                            <FormTemplate>
                                                <table cellspacing="2" cellpadding="1" width="100%" border="0">
                                                    <tr>
                                                    <td>
                                                        Degree:</td>
                                                    <td>
                                                        <asp:TextBox Width="200px" ID="TextBox1" runat="server" Text='<%# Bind("Title") %>' MaxLength="50"></asp:TextBox>
                                                        <asp:requiredfieldvalidator id="ReqTextBox1" runat="server" ErrorMessage="*" EnableClientScript="False"
                                                                                    ControlToValidate="TextBox1" Display="Static" />
                                                    </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Area:
                                                        </td>
                                                        <td>
                                                            <asp:TextBox Width="200px" ID="TextBox2" runat="server" Text='<%#Bind("Area") %>' MaxLength="200"></asp:TextBox>
                                                            <asp:requiredfieldvalidator id="ReqTextBox2" runat="server" ErrorMessage="*" EnableClientScript="False"
                                                                                    ControlToValidate="TextBox2" Display="Static"  />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Institution:
                                                        </td>
                                                        <td>
                                                            <asp:TextBox Width="200px" ID="TextBox5" runat="server" Text='<%#Bind("CompanyName") %>' MaxLength="200"></asp:TextBox>
                                                            <asp:requiredfieldvalidator
                                                                                       id="ReqTextBox5"
                                                                                       runat="server"
                                                                                       ErrorMessage="*"
                                                                                       EnableClientScript="False"
                                                                                       ControlToValidate="TextBox5"
                                                                                       Display="Static"  />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Date:</td>
                                                        <td>
                                                            <asp:TextBox Width="200px" ID="TextBox4" runat="server" Text='<%#Bind("Year") %>'/>                                                         
                                                        </td>
                                                            
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <asp:Label ID="ErrorMessage" runat="server"  EnableViewState="false" Visible="false" Text="Entry already exists." ForeColor="Red" />
                                                            <br></br>
                                                            <asp:LinkButton
                                                                            ID="Button1"
                                                                            runat="server"
                                                                            Text='<%# (Container is GridEditFormInsertItem) ? "Save" : "Update" %>'
                                                                            CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' />
                                                            <asp:LinkButton
                                                                           ID="Button2"
                                                                           runat="server"
                                                                           Text="Cancel"
                                                                           CausesValidation="false"
                                                                           CommandName="Cancel" />
                        
                                                        </td>
                                                    </tr>
                                                </table>
                                            </FormTemplate>
                                        </EditFormSettings>
                    </MasterTableView>                  
                    <FilterMenu EnableTheming="True">
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                    </FilterMenu>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>


<pp:ObjectContainerDataSource ID="MyDataSource" runat="server"                          
        DataObjectTypeName = "MVPWithCWABQuickStart.HelloWorld.BusinessEntities.MyEntity"
        oninserted="MyDataSource_Inserted"
        ondeleted="MyDataSource_Deleted" />

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Code-behind

 protected void MyDataSource_Inserted(object sender, Microsoft.Practices.Web.UI.WebControls.ObjectContainerDataSourceStatusEventArgs e)
        {
         
        }
        protected void MyDataSource_Deleted(object sender, Microsoft.Practices.Web.UI.WebControls.ObjectContainerDataSourceStatusEventArgs e)
        {
         
        }


 protected void myGrid_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditFormItem editedItem = e.Item as GridEditFormItem;

                TextBox txt1 = editedItem.FindControl("TextBox4") as TextBox;
               if (txt1 != null)
                {
                    RegExpTextBoxSetting regExpSetting = (RegExpTextBoxSetting)RadDegreesManager.GetSettingByBehaviorID("RegExpBehavior1");
                    regExpSetting.TargetControls.Add(new TargetInput(txt1.UniqueID, true));
                }
            }

            if (e.Item is GridDataItem && !e.Item.IsInEditMode && e.Item.DataItem != null) //Checks that the item is a GridDataItem, is not in Edit mode and is not NULL
            {
                DateTime datetime;
                if (DateTime.TryParse(((ProfileDegree)e.Item.DataItem).Year, out datetime))
                {
                    ((ProfileDegree)e.Item.DataItem).Year = String.Format("{0:MMM/yyyy}", datetime); //Change the format of the date to MMM/yyyy (e.g. Jan/2010)
                }
            }
        }



 protected void myGrid_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked
            {
                e.Canceled = true;
                var newValues = new System.Collections.Specialized.ListDictionary();
                newValues["Title"] = string.Empty;
                newValues["Area"] = string.Empty;
                newValues["CompanyName"] = string.Empty;
                newValues["Year"] = string.Empty;
                //Insert the item and rebind
                e.Item.OwnerTableView.InsertItem(newValues);
            }
            if (e.Item.ItemType == GridItemType.EditFormItem)
            {
                if (e.CommandName == "PerformInsert")
                {
                    TextBox titleTextBox = (TextBox)e.Item.FindControl("TextBox1");
                    TextBox areaTextBox = (TextBox)e.Item.FindControl("TextBox2");
                    TextBox companyTextBox = (TextBox)e.Item.FindControl("TextBox5");
                    TextBox yearTextBox = (TextBox)e.Item.FindControl("TextBox4");
                    Label errorMessage = (Label)e.Item.FindControl("ErrorMessage");

                    if (titleTextBox != null && areaTextBox != null && companyTextBox != null && yearTextBox != null)
                    {
                        //If the addition operation was not triggered from a refresh, do the database insert.
                        e.Canceled = expertiseDateValidationCancel(yearTextBox, degreeErrorMessage);
                        if (!e.Canceled)
                        {
                            MyEntity metaData = new MyEntity();
                            metaData.Degree = titleTextBox.Text;
                            metaData.Area = areaTextBox.Text;
                            metaData.InstitutionName = companyTextBox.Text;
                            metaData.Year = yearTextBox.Text;
                    

                           if(InsertObject(metaData))
                            {
                                errorMessage.Visible = true;
                                e.Canceled = true;
                            }
                          
                        }
                    }
                    else
                        errorMessage.Visible = true;
                }
            }
        }



My problem is that the required field validators in the edit form of the grid are not being fired or at least the validation do not stop the postback of the command, because I can see that Page.IsValid property is false when debugging myGrid_ItemCommand. Do you have an idea of what could be happening. my understanding is that there should not be a postback when the form is empty. I have tried using validation groups, removing the radPanel and the RadInputManager but still no luck. I know that I could stop the execution of the command using something like this:

if(!Page.IsValid)
{
 e.Cencled = true;
return;
}

but I want to avoid the post back.

I'm using RadControls for ASPNET AJAX Q1 2009 (2009.1.527.35)

Thank you for your help!!!
Gerardo Perez
Top achievements
Rank 1
 answered on 23 Feb 2010
3 answers
488 views
I am having difficulty working with the pie chart and getting the actual pie slices to render effectively.

Can you change the scale of a pie chart?  The problem that I am having is when I have a single value that encompasses 90% of the chart, the other pie slices and their labels are overlapping.

I've already tried setting Intelligent labels, setting margins on the textblocks, etc.  The labels are multi-line too.  I've set the maxlength to 50.

If you create a pie chart with the following values, you will see what I mean:

chartSeries.AddItem(30670.80,

"Infrastructure \n30,670");

 

chartSeries.AddItem(776.30,

"Energy \n$776");

 

chartSeries.AddItem(295.30,

"Education and Training \n$295");

 

chartSeries.AddItem(378021.30,

"Protecting the Vulnerable \n$378,021");

 

chartSeries.AddItem(50.00,

"Other \n$50");

I am at a loss on what else to change in order to get the labels to stop overlapping each other or get the smaller percentage pie slices to show better or bigger.

Any assistance would be greatly appricated.

Thanks,
Dawn

 

Schlurk
Top achievements
Rank 2
 answered on 23 Feb 2010
1 answer
100 views

Hi guys
 I am having one excel sheet with 10,000 records and want to upload that records into database , but when uploading that records i want the status to be updated to UI layer how many number of records uploaded into database remaing records count etc with progressive bar.

 

Is it possible with Telerik please give the code for processing this...

 

Thanks & Regards

Amarnath Reddy Mitta

Schlurk
Top achievements
Rank 2
 answered on 23 Feb 2010
5 answers
199 views
I am using paging on my grid with 

Mode

 

="NextPrev"

 


I load data into my grid from two different sources so if my pagesize is 20 then it gets max of 10 rows at one time from source1 and same goes for source2.
However, there might be cases when one or both of the source is returning less than 10 rows each.
In that case the number of items in the grid is less than 20.

I want to change the display message of the pager that says 'Displaying page 1 of 2, items 1 to 20 of 25'
I want the 'items 1to 20 of 25' to be changed to 'items 1 to (whatever is the row count for the current page) of 25'
So if page 1 has 15 records then it says 'items 1 to 15 of 25' and then on next page it says items 16 to 25 of 25'

Is there a way to do that?
if not Can I just hide the items part?
Daniel
Telerik team
 answered on 23 Feb 2010
4 answers
182 views
Hi

Is there any way to do export to Excel from the Schedular ?

Thanks
Archan
Peter
Telerik team
 answered on 23 Feb 2010
6 answers
261 views
Hello, I've been developing an application that has a Radgrid for a couple of months now, but I've ran into an issue I don't quite understand.

The situation is like this: I have implemented functionality that when a user is editing a row, and finishes doing so and wants to update the row, they can just press enter and the radgrid will update that row. I solved this by use of some code I found elsewhere on this forum, in javascript, like so:
function KeyPressEnter(sender, args)  
    {  
        if (args.get_keyCode() != 13)  
                return;  
 
            var el = Telerik.Web.UI.Grid.GetCurrentElement(args.get_domEvent());  
             
            if (el.tagName.toLowerCase() !='input' && el.tagName.toLowerCase() !='textarea') return;   
                if ($(el).parents("tr").attr("id") && $(el).parents("tr").attr("id") != "") {  
                sender.get_masterTableView().updateItem($(el).parents("tr")[0]);  
                }  
                             
    } 
This function is added to the .aspx under the clientsettings, with the clientevent onkeypress.

Now, I have gotten the assignment to do the same for inserting items. So, I tried to use the same code as above, only then with:
sender.get_masterTableView().insertItem($(el).parents("tr")[0]);
instead of the:
sender.get_masterTableView().updateItem($(el).parents("tr")[0]);
in the above code.

This however generates an error: " Insert item is available only when grid is in insert mode."
I found this odd, as the radgrid is indeed in insert mode when this method is called. Especially seeing as the insert will succeed if I just click the commandbutton to insert the item instead. I also called the method sender.get_masterTableView().get_isItemInserted() in that code, which always returns false. I even tried to force it into insertmode using sender.get_masterTableView().showInsertItem($(el).parents("tr")[0]); ,as one of your pages on this subject suggests that this should put the grid into insert mode, but to no avail. get_isItemInserted() keeps returning false.

Would anyone have any idea how I'll be able to solve my problem?
Veli
Telerik team
 answered on 23 Feb 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?