将大量数据绑定到组合框?

时间:2021-10-14 16:54:32

I want to bind list of employees in drop down list , with autocomplete feature so the user can search the proper name .i use RadComboBox

我想在下拉列表中绑定员工列表,带有自动完成功能,用户可以搜索正确的名字。我使用RadComboBox

I have two main problems :

我有两个主要问题:

1- The list is so large about 5000 item.so binding this large number of data in the browser make it hang or so slow.(performance issue)

1-这个清单太大了,大概有5000个项目。因此,将大量的数据绑定到浏览器中,就会使其挂起或很慢。(性能问题)

According to the Telerik Documentation

根据Telerik文件

Set a data source to the RadComboBox. Use either DataSourceID or the DataSource property to do this and set the DataTextField and DataValueField properties to the respective fields in the data source. (Note that when using DataSource you must set the property on each postback, most conveniently in Page_Init.) Set EnableAutomaticLoadOnDemand to true.

将数据源设置为RadComboBox。使用DataSourceID或DataSource属性执行此操作,并将DataTextField和DataValueField属性设置为数据源中的相应字段。(注意,在使用DataSource时,必须在每个回发上设置属性,在Page_Init中最方便。)EnableAutomaticLoadOnDemand设置为true。

so i have to call the following method every time in Page_Init !!!

所以每次在Page_Init中我都必须调用以下方法!!!

  protected void BindInnerInstructors()
    {
        ddl_inner_sup.Items.Clear();
        ddl_inner_sup.DataSource = Utilities.GetAllInnerInstructors();
        ddl_inner_sup.DataValueField = "emp_num";
        ddl_inner_sup.DataTextField = "name";
        ddl_inner_sup.DataBind();
    }

2- Object reference not set to an instance of an object when trying to set the selection of a combo box.

2-当试图设置组合框的选择时,对象引用没有设置为对象的实例。

i overcome this problem through this.

我通过这个解决了这个问题。


I have about 4 dropdowlists but every one have to bind in according to an event but i have to bind all of them in the page_init.

我有大约4个dropdowlist但每个都必须根据事件绑定,但我必须在page_init中绑定它们。

I'll be grateful to a detailed answer to this problem .

我将很感激这个问题的详细答案。

8 个解决方案

#1


8  

my company had a similar issue. we ended up using a jquery object called Select2 and we lazy load the list. Basically we load only the first 10 or so at load time, making it fast to load, and if the user scrolls down past the first 10 we load the next 10 and so on. Select2 has a search feature which hits the server to return a custom list based on the search.

我的公司也有类似的问题。最后,我们使用了一个名为Select2的jquery对象,我们延迟加载列表。基本上,我们只在加载时加载前10个左右,使加载速度更快,如果用户滚动到前10个之后,我们就加载下10个,以此类推。Select2有一个搜索功能,它会访问服务器,根据搜索返回自定义列表。

the problem with loading 5000 elements all at once is that the browser will take forever to load them, iterate through them, and manipulate them as needed. I am not saying "you must use select2" RadComboBox may have something like this you can use.

同时加载5000个元素的问题是浏览器会花很长时间来加载它们,迭代它们,并根据需要操作它们。我并不是说“你必须使用select2”RadComboBox可能有这样的东西你可以使用。

Good luck.

祝你好运。

#2


2  

I had a same issue in radcombobox. Finally i got a solution and posted in my company blog.

我在radcombobox也有同样的问题。最后,我找到了一个解决方案,并把它发布在了我的公司博客上。

Refer the following link.

请参考下面的链接。

http://elintsys.co.in/blogs/post/2013/06/07/RAD-Combo-box-text-search-browser-uses-100-CPU

http://elintsys.co.in/blogs/post/2013/06/07/rad -组合框-文本搜索浏览器-使用- 100 cpu

I think this would help you. Cheers

我想这会对你有帮助。干杯

#3


1  

I do not reccomend showing the data set, but instead storing it in a javascript object. You can then do autocomplete with that list of objects. This is done via jquery, using a selector, and then applying an auto complete function with it.

我不重新显示数据集,而是将它存储在一个javascript对象中。然后,您可以对该对象列表进行自动完成。这是通过jquery完成的,使用一个选择器,然后使用它应用一个自动完成函数。

Example:

例子:

var systems = [{t:"hi",s:"something"}.{t:"hi",s:"something"},{t:"hi",s:"something"}];
$("#s").autocomplete(systems, 
{
width: 300,
formatItem: function(item) 
{ return item.t + item.s; },
formatResult: function(item) 
{ return item.t; }
});

#4


1  

I also met a similar scenario where very large number of values were bind to dropdownlist. Latest version of chrome, firefox and IE was able to bind that but that too take about minutes, but for older version script hangs & never works.

我还遇到过类似的情况,在这种情况下,会将大量的值绑定到dropdownlist。最新版本的chrome, firefox和IE可以绑定,但是那也需要几分钟,但是对于旧版本的脚本挂起,永远不会工作。

Instead of using any custom control or telerik rad box, we use simple approach. We take page-size as configurable value(say 50) and page number(default 1) ,number of pages (Total count/ page size) and search criteria(User input for auto-complete) as parameter for service returning value and fetch only records equal to page-size as per input search criteria & page number.

我们不使用任何自定义控件或telerik rad框,而是使用简单的方法。我们将页面大小作为可配置值(比如50)和页码(默认值1)、页面数量(总数/页面大小)和搜索条件(自动完成用户输入)作为服务返回值的参数,根据输入搜索条件和页码只获取与页面大小相等的记录。

Take a text-box & bind this service call to text-change event of the text box & bind output to autocomplete dropdown.

获取文本框并将此服务调用绑定到文本框的文本更改事件,并将输出绑定到自动完成下拉列表。

The logic for paging & search is implemented in stored procedure like Stored Procedure having Sorting, Paging and Filtering

分页和搜索的逻辑是在存储过程中实现的,如具有排序、分页和筛选的存储过程

This was easy, fast and pretty much maintainable than any client-side paging, binding etc.

这比任何客户端分页、绑定等都简单、快速且易于维护。

#5


1  

Drop down list is not well suited for a full list of employees. Someone needs to rethink the design.

下拉列表不适合完整的员工列表。有人需要重新考虑设计。

#6


1  

Use a VirtualizingStackPanel as ItemsPanel for your RadComboBoxes if there is a large number of items to be displayed. With a VirtualizingStackPanel you can have ten-thousands of items in your RadComboBox.

如果有大量的项目需要显示,请使用一个VirtualizingStackPanel作为radcombobox的ItemsPanel。使用一个VirtualizingStackPanel,你可以在你的RadComboBox中有上万个条目。

Use this XAML-Code:

使用这个XAML-Code:

            <!-- WPF ItemsControls like ComboBox, ListBox or Menu use a StackPanel as their internal layout panel. 
                 Use a VirtualizingStackPanel for performance. Else the Combobox will freeze!   -->
            <ItemsPanelTemplate x:Key="itemsPanelTemplate">
                <VirtualizingStackPanel />
            </ItemsPanelTemplate>

            <!-- This style specifies how RadComboBoxes look like -->
            <Style TargetType="telerik:RadComboBox">
                <Setter Property="ItemsPanel" Value="{StaticResource itemsPanelTemplate}"/>
            </Style>

#7


0  

For simplicity u just add the first 15 or 20 names and when user types on the combobox, fill combobox with returned names from database but not all, fill it with just few names only so the browser will not hung...

为了简单起见,您只需添加前15或20个名称,当用户在combobox上键入时,请在combobox中填充数据库返回的名称,但不是全部,只填充几个名称,这样浏览器就不会挂起……

#8


0  

You can do the same thing as google does. When you write something on google, the text that don't same as you've typed will disappear but the same ones will stay there. This will make your searching easier, this is the answer.

你可以和谷歌做同样的事情。当你在谷歌上写东西的时候,和你键入的内容不一样的文本将会消失,但是相同的文本会留在那里。这将使你的搜索更容易,这是答案。

#1


8  

my company had a similar issue. we ended up using a jquery object called Select2 and we lazy load the list. Basically we load only the first 10 or so at load time, making it fast to load, and if the user scrolls down past the first 10 we load the next 10 and so on. Select2 has a search feature which hits the server to return a custom list based on the search.

我的公司也有类似的问题。最后,我们使用了一个名为Select2的jquery对象,我们延迟加载列表。基本上,我们只在加载时加载前10个左右,使加载速度更快,如果用户滚动到前10个之后,我们就加载下10个,以此类推。Select2有一个搜索功能,它会访问服务器,根据搜索返回自定义列表。

the problem with loading 5000 elements all at once is that the browser will take forever to load them, iterate through them, and manipulate them as needed. I am not saying "you must use select2" RadComboBox may have something like this you can use.

同时加载5000个元素的问题是浏览器会花很长时间来加载它们,迭代它们,并根据需要操作它们。我并不是说“你必须使用select2”RadComboBox可能有这样的东西你可以使用。

Good luck.

祝你好运。

#2


2  

I had a same issue in radcombobox. Finally i got a solution and posted in my company blog.

我在radcombobox也有同样的问题。最后,我找到了一个解决方案,并把它发布在了我的公司博客上。

Refer the following link.

请参考下面的链接。

http://elintsys.co.in/blogs/post/2013/06/07/RAD-Combo-box-text-search-browser-uses-100-CPU

http://elintsys.co.in/blogs/post/2013/06/07/rad -组合框-文本搜索浏览器-使用- 100 cpu

I think this would help you. Cheers

我想这会对你有帮助。干杯

#3


1  

I do not reccomend showing the data set, but instead storing it in a javascript object. You can then do autocomplete with that list of objects. This is done via jquery, using a selector, and then applying an auto complete function with it.

我不重新显示数据集,而是将它存储在一个javascript对象中。然后,您可以对该对象列表进行自动完成。这是通过jquery完成的,使用一个选择器,然后使用它应用一个自动完成函数。

Example:

例子:

var systems = [{t:"hi",s:"something"}.{t:"hi",s:"something"},{t:"hi",s:"something"}];
$("#s").autocomplete(systems, 
{
width: 300,
formatItem: function(item) 
{ return item.t + item.s; },
formatResult: function(item) 
{ return item.t; }
});

#4


1  

I also met a similar scenario where very large number of values were bind to dropdownlist. Latest version of chrome, firefox and IE was able to bind that but that too take about minutes, but for older version script hangs & never works.

我还遇到过类似的情况,在这种情况下,会将大量的值绑定到dropdownlist。最新版本的chrome, firefox和IE可以绑定,但是那也需要几分钟,但是对于旧版本的脚本挂起,永远不会工作。

Instead of using any custom control or telerik rad box, we use simple approach. We take page-size as configurable value(say 50) and page number(default 1) ,number of pages (Total count/ page size) and search criteria(User input for auto-complete) as parameter for service returning value and fetch only records equal to page-size as per input search criteria & page number.

我们不使用任何自定义控件或telerik rad框,而是使用简单的方法。我们将页面大小作为可配置值(比如50)和页码(默认值1)、页面数量(总数/页面大小)和搜索条件(自动完成用户输入)作为服务返回值的参数,根据输入搜索条件和页码只获取与页面大小相等的记录。

Take a text-box & bind this service call to text-change event of the text box & bind output to autocomplete dropdown.

获取文本框并将此服务调用绑定到文本框的文本更改事件,并将输出绑定到自动完成下拉列表。

The logic for paging & search is implemented in stored procedure like Stored Procedure having Sorting, Paging and Filtering

分页和搜索的逻辑是在存储过程中实现的,如具有排序、分页和筛选的存储过程

This was easy, fast and pretty much maintainable than any client-side paging, binding etc.

这比任何客户端分页、绑定等都简单、快速且易于维护。

#5


1  

Drop down list is not well suited for a full list of employees. Someone needs to rethink the design.

下拉列表不适合完整的员工列表。有人需要重新考虑设计。

#6


1  

Use a VirtualizingStackPanel as ItemsPanel for your RadComboBoxes if there is a large number of items to be displayed. With a VirtualizingStackPanel you can have ten-thousands of items in your RadComboBox.

如果有大量的项目需要显示,请使用一个VirtualizingStackPanel作为radcombobox的ItemsPanel。使用一个VirtualizingStackPanel,你可以在你的RadComboBox中有上万个条目。

Use this XAML-Code:

使用这个XAML-Code:

            <!-- WPF ItemsControls like ComboBox, ListBox or Menu use a StackPanel as their internal layout panel. 
                 Use a VirtualizingStackPanel for performance. Else the Combobox will freeze!   -->
            <ItemsPanelTemplate x:Key="itemsPanelTemplate">
                <VirtualizingStackPanel />
            </ItemsPanelTemplate>

            <!-- This style specifies how RadComboBoxes look like -->
            <Style TargetType="telerik:RadComboBox">
                <Setter Property="ItemsPanel" Value="{StaticResource itemsPanelTemplate}"/>
            </Style>

#7


0  

For simplicity u just add the first 15 or 20 names and when user types on the combobox, fill combobox with returned names from database but not all, fill it with just few names only so the browser will not hung...

为了简单起见,您只需添加前15或20个名称,当用户在combobox上键入时,请在combobox中填充数据库返回的名称,但不是全部,只填充几个名称,这样浏览器就不会挂起……

#8


0  

You can do the same thing as google does. When you write something on google, the text that don't same as you've typed will disappear but the same ones will stay there. This will make your searching easier, this is the answer.

你可以和谷歌做同样的事情。当你在谷歌上写东西的时候,和你键入的内容不一样的文本将会消失,但是相同的文本会留在那里。这将使你的搜索更容易,这是答案。