Asp.net+jquery a Drop-down control that loads data with a scrolling scroll bar _jquery

Source: Internet
Author: User
This kind of demand seems to feel not very reasonable, because the data is so much the pull from the human or machine operations are more painful.

No way because of the demand down, can only operate as required. On the internet to find a lot of related controls are feeling a bit large, accounting for more resources. No way to spend half a day to make a custom control of semi-finished products, take out share, such as a master see please more guidance.

Requirements: Ajax scrolling scroll bar loading data drop-down list
Control Name: Webcombo
Technology used: asp.net (C #), jquery,asp. NET General processing file (. ashx)

Drop-down list specific implementation: Using DIV simulation drop-down list, input and picture simulation Drop-down box. The final results are shown below


Let's analyze the plugin on the jquery side.
Ajax loaded with jquery Ajax complete
Copy Code code as follows:

$.ajax ({
Type:options.getMethod,
URL:OPTIONS.JSONURL,
Data:params,
Success:function (data) {
if (Isscroll)
$. Createlistitem (showbox,data,options);
Else
$. Createbox (showbox,data,options);
},
Complete:function () {},
Error:function (e) {
$ (options.loadbox). CSS (' background-image ', ' none ');
$ (Options.loadbox). Append (' <span>data connect error! ' +e+ ' </span> ');
}

The scroll bar scrolling load data is completed by the Onscroll event of the dropdown Div, the core code is as follows:

Copy Code code as follows:

$ (Showbox). Scroll (function () {
if (options.total==$ (this). Children ("ul"). Children ("Li"). Length)
Return
var scrolltop=$ (Showbox). attr (' scrolltop ');
var scrollheight=$ (Showbox). attr (' scrollheight ');
var windowheight=$ (Showbox). attr (' clientheight ');
var scrolloffset=20;
$ (options.loadbox). CSS (' top ', scrolltop);
if (scrolltop>= (scrollheight-(windowheight+scrolloffset)) &&!loading)
{
Loading=true;
$ (Options.loadbox). Show ();
options.total=$ (This). Children ("ul"). Children ("Li"). length;
$. Webcombogetdata (showbox,options,true);
}
});

The plugin's complete code can be found in the source file, file name: simulateddl.js
In fact, this scroll bar scrolling data to load the jquery plug-in has been written to achieve this functionality, just because the project used in the place more and more rogue to encapsulate it into the ASP.net custom control. The reason why the semi-finished is this custom control customization of some of the humanization, the experts see the guidance. Specific code can be downloaded after viewing, I am not a control production master, will not move out of the shortcoming. The friend who has the question suggestion may propose to discuss the discussion.

Asp.net+jquery scroll bar scrolling load Data Control source code download
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.