Error: Length of elements and json must be the same!

15 posts, 0 answers
  1. Imtiaz
    Imtiaz  avatar
    11 posts
    Member since:
    Apr 2008

    Posted 30 Jun 2008 Link to this post

    t
  2. Shirley Linscott
    Shirley Linscott avatar
    1 posts
    Member since:
    Nov 2007

    Posted 31 Jul 2008 Link to this post

    i also get  this json message: Assertion Failed: Length of elements and json must be the same. Break into debugger?

    I have two combos that are stringed together. On client itemsRequested of first combo, i clear second combo text, clear items, RequestItems for second combo, and set text to first item of second combo. I start getting that message if i change the text of first combo. Does anybody know how to get rid of or suppress that message? code is below:

    <

    telerik:RadComboBox

    id="RadComboBox1"

    Runat="server"

    Height="140px"

    width="150px"

    EnableLoadOnDemand="True"

    AllowCustomText="True"

    ItemRequestTimeout="500"

    MarkFirstMatch="True"

    OnClientFocus="OnClientFocus"

    OnClientItemsRequesting="StopRequesting"

    OnItemsRequested="RadComboBox1_ItemsRequested"

    OnClientItemsRequested='ComboItemsRequestedWO'

    Text='<%# Bind("WONum") %>'

    >

    </telerik:RadComboBox> </td>

    <td style="width: 48px; height: 87px;">Charge Code:</td>

    <td style="height: 87px"><telerik:RadComboBox

    id="RadComboBoxCC"

    Runat="server"

    Height="140px"

    width="150px"

    ShowMoreResultsBox="True"

    AllowCustomText="True"

    ItemRequestTimeout="500"

    OnItemsRequested="RadComboBoxCC_ItemsRequested"

    Text='<%# Bind("ChargeCode") %>'

    >

    </telerik:RadComboBox></td>

    <

    script language="javascript" type="text/javascript">

    function ComboItemsRequestedWO()

    {

    Telerik.Web.UI.RadComboBox.ComboBoxes[1].set_text(

    "");

    Telerik.Web.UI.RadComboBox.ComboBoxes[2].set_text(

    "");

    alert(

    "set text to nothing");

    var items = Telerik.Web.UI.RadComboBox.ComboBoxes[1].get_items();

    items.clear();

    alert(

    "cleared cc items");

    items = Telerik.Web.UI.RadComboBox.ComboBoxes[2].get_items();

    items.clear();

    alert(

    "cleared loc items");

    Telerik.Web.UI.RadComboBox.ComboBoxes[1].requestItems(

    "ChargeCode", true);

    var strSelectText = "";

    var itemsCC = Telerik.Web.UI.RadComboBox.ComboBoxes[1].get_items();

    alert(

    "got items");

    strSelectText = itemsCC.getItem(0).get_text();

    alert(strSelectText);

    Telerik.Web.UI.RadComboBox.ComboBoxes[1].set_text(strSelectText);

    alert(

    "set cc");

    alert(

    "finished");

    }

    </

    script>

    <script language="javascript" type="text/javascript">

    function StopRequesting(sender, eventArgs)

    {

    if (sender.get_text().length < 9)

    {

    eventArgs.set_cancel(

    true);

    }

    }

    </

    script>

    Protected Sub RadComboBox1_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs)

    Dim db As Database = DatabaseFactory.CreateDatabase("JSAS_DevConnectionString")

    Dim sqlCmd As String = "spJSAS_GetWONumOnDemand"

     

     

    Dim dbCmd As SqlCommand = db.GetStoredProcCommand(sqlCmd)

    db.AddInParameter(dbCmd,

    "@WONum", DbType.String, e.Text)

    Dim reader As IDataReader = db.ExecuteReader(dbCmd)

    Dim combo As Telerik.Web.UI.RadComboBox = o

    While reader.Read()

    Dim item As Telerik.Web.UI.RadComboBoxItem = New Telerik.Web.UI.RadComboBoxItem(reader("WONum").ToString)

    combo.Items.Add(item)

     

    End While

    Session(

    "WoNum") = e.Text

    End Sub

    Protected Sub RadComboBoxCC_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs)

    Dim db As Database = DatabaseFactory.CreateDatabase("JSAS_DevConnectionString")

    Dim sqlCmd As String = "spJSAS_GetChargeCode"

     

     

    Dim dbCmd As SqlCommand = db.GetStoredProcCommand(sqlCmd)

    db.AddInParameter(dbCmd,

    "@WONum", DbType.String, Session("WONum").ToString())

    Dim reader As IDataReader = db.ExecuteReader(dbCmd)

     

    Dim combo As Telerik.Web.UI.RadComboBox = o

    combo.Items.Clear()

     

    While reader.Read()

    Dim item As Telerik.Web.UI.RadComboBoxItem = New Telerik.Web.UI.RadComboBoxItem(reader("ChargeCode").ToString)

    combo.Items.Add(item)

    End While

     

    End Sub



  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 01 Aug 2008 Link to this post

    Hello Shirley ,

    Thanks for bringing this to our attention.

    We have logged this in our bug tracking system and we will fix it for the next version of the control.
    Meanwhile I suggest you try the following code:
    sender.get_items().forEach(function(item){ if(item) item.get_comboBox().get_items().remove(item)});

    instead of  items.clear();

    Let us known how this goes.

    Regards,
    Rosi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Vithiya
    Vithiya avatar
    41 posts
    Member since:
    May 2008

    Posted 23 Sep 2008 Link to this post

    Did this issue ever get resolved? I am having the exact same problem.

    Thank you!
    vithiya
  6. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 24 Sep 2008 Link to this post

    Hello Vithiya,

    Please find attached our latest official version.

    This should fix the problem.

    Regards,
    Rosi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. sl6rp
    sl6rp avatar
    55 posts
    Member since:
    Sep 2012

    Posted 13 Oct 2008 Link to this post

    I still get this error on occasion when I use load on demand in a combobox.  I have a page that has several tabs.  On one I have a load on demand combobox with a template.  It typically only has 10-80 items.  I load 10 at a time.  It laods the first 10 items in under a second. 

    On another tab, I have a load on demand combobox that can have several thousand items.  Again I only load 10 at a time.  The first 10 can take 10 - 15 seconds to load.  After that it works fairly well.  It is the inital load that my clients are seeing the JSON error.  The combobox still loads but I would prefer they don't see the error and that the inital load time is quicker.

    I am using the 2008.2.826.35 dll.
  8. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 14 Oct 2008 Link to this post

    Hello ,

    I suggest you try our latest official build - 2008.2.1001. If the problem still persists, please send us a sample running project illustrating the issue.

    As for the performance please read - Combobox callback is slow.


    Regards,
    Rosi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Chris
    Chris  avatar
    1 posts
    Member since:
    Mar 2008

    Posted 25 Feb 2009 Link to this post

    I am also getting this error message using version 2008.2.1001.35.  The error occurs after loading a combo box using the ItemsRequested handler where the combo list items contain at least one items that is marked visible = false.  (I am making items invisible so that inactive items can be displayed but not selected should a user choose to modify the combo value.)

    For item lists with no invisible items, I don't get the error when populating using the itemsrequested handler.  I also get no error when loading the combo via a page load handler regardless of the combo having invisible items.

    I tried the suggestion to avoid the Items.clear method, but that had no affect on the outcome. 

    This is going to be a major problem for me when I have to inactivate items.

    Here is my code:

    radComboBox.Items.Clear();

     

    foreach (TableItem tblItem in itemList)

     

     

     {

        

    RadComboBoxItem cboItem = new RadComboBoxItem(tblItem.ItemName, tblItem.ItemId.ToString()); 
        cboItem.Visible = tblItem.Active;
        radComboBox.Items.Add(cboItem);

     

     

    }

     

     

  10. rupali kulkarni
    rupali kulkarni avatar
    2 posts
    Member since:
    Aug 2009

    Posted 20 Aug 2009 Link to this post

    Hi Rosi,
    How to use sender.get_items().forEach(function(item){ if(item) item.get_comboBox().get_items().remove(item)});
    this code

    I have simple RadComboBox as below and i want to clear all the items in item requested before binding new data

     

    <telerik:RadComboBox ID="AutoRadComboBox" runat="server" Width="254px" Height="150px"  

     

    EmptyMessage="Click to select value" EnableLoadOnDemand="True" ShowMoreResultsBox="true"  

     

    AutoPostBack="true" EnableVirtualScrolling="true" OnItemsRequested="AutoRadComboBox_ItemsRequested"  

     

    OnSelectedIndexChanged="AutoRadComboBox_SelectedIndexChanged"  

     

    onitemdatabound="AutoRadComboBox_ItemDataBound"  

     

    AppendDataBoundItems ="false"  

     

    Skin="Sunset">  

     

    </telerik:RadComboBox>


    C# code

     

    AutoRadComboBox.DataSource = dvBrowse.Table;

    AutoRadComboBox.DataBind();

    I have this in item requested, but the previous values are not getting removed after binding new datatable.

    Regards
    Rupali

     

  11. Raj
    Raj avatar
    6 posts
    Member since:
    Dec 2009

    Posted 07 Dec 2009 Link to this post

    Hello Friends,

    Does any one hve solution of this error? I am getting this error


    Regards,

    Kunal
  12. Bleble Skeble
    Bleble Skeble avatar
    1 posts
    Member since:
    Nov 2009

    Posted 08 Mar 2010 Link to this post

    I have same error msg using RadPanelBar...
    RadPanelBar rpb; 
    in init
    rpb = new RadPanelBar(); 
    rpb.ID = "rpb"
    rpb.Width = 1140; 
    rpb.Height = 500; 
    rpb.ExpandMode = PanelBarExpandMode.MultipleExpandedItems; 
     
    rpb.Items.Add(new RadPanelItem("Group one")); 
    rpb.Items.Add(new RadPanelItem("Group two")); 
     
    rpb.Items[0].Items.Add(new RadPanelItem()); 
    rpb.Items[1].Items.Add(new RadPanelItem()); 
    rpb.Items[1].Items.Add(new RadPanelItem()); 
     
    rpb.Items[0].Expanded = false
      
    rpb.Items[0].Items[0].Value = "val1"
    rpb.Items[0].Items[0].Controls.Add(controlI); 
     
    rpb.Items[1].Expanded = true
     
    rpb.Items[1].Items[0].Value = "val2"
    rpb.Items[1].Items[0].Controls.Add(controlII); 
     
    rpb.Items[1].Items[1].Value = "val3"
    rpb.Items[1].Items[1].Controls.Add(controlIII); 
    where controlI, controlII and controlIII are different Controls, for example:
    controlIII = new Control(); 
     
    UpdatePanel updatePanelIII = new UpdatePanel(); 
    updatePanelIII.ID = "updatePanelIII"
    updatePanelIII.UpdateMode = UpdatePanelUpdateMode.Conditional; 
     
    Panel panelIII = new Panel(); 
    panelIII.ID = "panelIII"
    panelIII.Style.Add("margin-left""10px"); 
     
    panelIII.Controls.Clear(); 
     
    panelIII.Controls.Add(new LiteralControl("<table><tr><td>")); 
    panelIII.Controls.Add(lblPocetKusuPridaniPolozkyPresKod);//some Label 
    panelIII.Controls.Add(txtPocetKusuPridaniPolozkyPresKod);//some textbox 
    panelIII.Controls.Add(new LiteralControl("</td><td>")); 
    panelIII.Controls.Add(lblPridejDleCisla);//some Label 
    panelIII.Controls.Add(txtPridejDleCisla);//some textbox 
    panelIII.Controls.Add(lblPridejDleCislaHlaska);//some Label 
    panelIII.Controls.Add(new LiteralControl("</td><td>")); 
    panelIII.Controls.Add(imgbtnPridatDleCislaDokladu);//some imagebutton 
    panelIII.Controls.Add(new LiteralControl("</td><td>")); 
    panelIII.Controls.Add(btnSmazatVybraneKarty);//some button 
    panelIII.Controls.Add(new LiteralControl("</td></tr>")); 
    panelIII.Controls.Add(new LiteralControl("<tr><td>")); 
    panelIII.Controls.Add(btnVyberKartyProDoklad);//some button 
    panelIII.Controls.Add(new LiteralControl("</td></tr></table>")); 
     
    updatePanelIII.ContentTemplateContainer.Controls.Add(panelIII); 
    updatePanelIII.Update(); 
     
    controlIII.Controls.Add(updatePanelIII); 
    each control if its added alone works properly, but when i add more than one it causes that Length of elements and json must be the same!


  13. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 10 Mar 2010 Link to this post

    Hi Bleble Skeble,

    It us unclear what exactly is causing this issue.

    I created a simple page (attached to this post) using your code and was unable to reproduce the issue.

    Can you please provide me with the full code of a page where the issue is clearly observed?

    Best wishes,
    Simon
    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.
  14. Louis
    Louis avatar
    9 posts
    Member since:
    Jun 2009

    Posted 06 Apr 2010 Link to this post

    I am seeing this problem too.  I am doing both loading of combos on demand and with item templates, as well as populating literal controls within radpanels (within pageviews within master/content pages).

    Unfortunately our project is too complex to attach a repro.  I can provide the code that asserts though, if that will help:

    This starts at line 5525, Telerik.Web.UI.dll 2009.3.1314.35

    a.RadPanelBar._createChildControls=function(e,f){var d=e.get_itemData();  
    if(!d){return;  
    }var c=e.get_childListElement();  
    if(!c){return;  
    }var j=$telerik.getChildrenByTagName(c,"li");  
    Sys.Debug.assert(d.length==j.length,"Length of elements and json must be the same!");  
    for(var g=0;  
    g<d.length;  
    g++){var h=new a.RadPanelItem();  
    f.add(h);  
    h._initialize(d[g],j[g]);  
    }}; 
  15. Louis
    Louis avatar
    9 posts
    Member since:
    Jun 2009

    Posted 06 Apr 2010 Link to this post

    Looks like I found my problem.  I'm building up html in code-behind and created a malformed tag.  I typed 'tdstyle='...'' instead of 'td style='...''.  After fixing the typo the error has gone away.  Hope this helps some of you!

    (edited to fix the typo where I mispelled typo, lol)
  16. Andrew Bort
    Andrew Bort avatar
    6 posts
    Member since:
    Sep 2009

    Posted 09 Aug 2011 Link to this post

    Just like Louis, I too was getting this error on my page where I was setting the .Text property of a Literal control to a string that included some poorly formed HTML markup (basically some bold tags).  Once I property closed the </b> tag, the error was resolved.  Thanks, Louis.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017