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

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

14 Answers 351 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Imtiaz
Top achievements
Rank 1
Imtiaz asked on 30 Jun 2008, 08:44 AM
t

14 Answers, 1 is accepted

Sort by
0
Shirley Linscott
Top achievements
Rank 1
answered on 31 Jul 2008, 01:40 PM
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



0
Rosi
Telerik team
answered on 01 Aug 2008, 10:12 AM
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.
0
Vithiya
Top achievements
Rank 1
answered on 23 Sep 2008, 06:48 PM
Did this issue ever get resolved? I am having the exact same problem.

Thank you!
vithiya
0
Rosi
Telerik team
answered on 24 Sep 2008, 07:18 AM
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.
0
sl6rp
Top achievements
Rank 1
answered on 14 Oct 2008, 02:54 AM
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.
0
Rosi
Telerik team
answered on 14 Oct 2008, 10:30 AM
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.
0
Chris
Top achievements
Rank 1
answered on 26 Feb 2009, 03:23 AM
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);

 

 

}

 

 

0
rupali kulkarni
Top achievements
Rank 1
answered on 20 Aug 2009, 04:17 PM
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

 

0
Raj
Top achievements
Rank 1
answered on 07 Dec 2009, 09:02 AM
Hello Friends,

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


Regards,

Kunal
0
Bleble Skeble
Top achievements
Rank 1
answered on 08 Mar 2010, 01:32 PM
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!


0
Simon
Telerik team
answered on 10 Mar 2010, 07:14 PM
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.
0
Louis
Top achievements
Rank 1
answered on 06 Apr 2010, 03:53 PM

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]);  
}}; 
0
Louis
Top achievements
Rank 1
answered on 06 Apr 2010, 04:24 PM
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)
0
Andrew Bort
Top achievements
Rank 1
answered on 09 Aug 2011, 04:50 PM
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.
Tags
ComboBox
Asked by
Imtiaz
Top achievements
Rank 1
Answers by
Shirley Linscott
Top achievements
Rank 1
Rosi
Telerik team
Vithiya
Top achievements
Rank 1
sl6rp
Top achievements
Rank 1
Chris
Top achievements
Rank 1
rupali kulkarni
Top achievements
Rank 1
Raj
Top achievements
Rank 1
Bleble Skeble
Top achievements
Rank 1
Simon
Telerik team
Louis
Top achievements
Rank 1
Andrew Bort
Top achievements
Rank 1
Share this question
or