一个工作流OA

源代码在线查看: jquery.agiletable.1.0.js

软件大小: 1386 K
上传用户: yxm_325
关键词:
下载地址: 免注册下载 普通下载 VIP

相关代码

				//	Version: 1.0
				//	Author: Spring.Cheung(spring.cheung@163.com)
				//	LastChangedDate: 2008-06-02
				//	Requires: jquery.1.2.3.js								jQuery.fn.agileTable = function(options)					{						options = jQuery.extend(							{								container: $(this).attr("id"),								key: "title",								separator: "|",								target: "Ids"							}, options);
						if (options.container != null && options.container != "" && options.target != null && options.target != "")
						{
							//	refresh items
							var target = $("#" + options.target);
							var header = $("th > :checkbox", $("#" + options.container));
							$("td > :checkbox", $("#" + options.container)).each(
								function()
								{
									var key = $(this).attr(options.key);
									var checked = target.val().indexOf(options.separator + key) >= 0;
									$(this).attr("checked", checked);
								});
							var checkeds = $("td > :checked", $("#" + options.container)).length;
							if (checkeds == 0)
							{
								$(header).attr("checked", false);
								$(header).removeAttr("indeterminate");
							}
							else if (checkeds < $("td > :checkbox", $("#" + options.container)).length)
							{
								$(header).attr("checked", false);
								$(header).attr("indeterminate", true);
							}
							else
							{
								$(header).attr("checked", true);
								$(header).removeAttr("indeterminate");
							}
							//	choose header
							$("th > :checkbox", $("#" + options.container)).click(
								function()
								{
									var checked = $(this).attr("checked") != null;
									$("td > :checkbox", $("#" + options.container)).each(
										function()
										{
											var key = $(this).attr(options.key);
											$(this).attr("checked", checked);
											if (checked)
											{
												target.val(target.val() + options.separator + key);
											}
											else
											{
												target.val(target.val().replace(options.separator + key, ""));
											}
										});
								});
							//	choose item
							$("td > :checkbox", $("#" + options.container)).click(
								function()
								{
									//	deal with current item
									var key = $(this).attr(options.key);
									var checked = $(this).attr("checked") != null;
									if (checked)
									{
										target.val(target.val() + options.separator + key);
									}
									else
									{
										target.val(target.val().replace(options.separator + key, ""));
									}
									//	deal with parent item
									checkeds = $("td > :checked", $("#" + options.container)).length;
									if (checkeds == 0)
									{
										$(header).attr("checked", false);
										$(header).removeAttr("indeterminate");
									}
									else if (checkeds < $("td > :checkbox", $("#" + options.container)).length)
									{
										$(header).attr("checked", false);
										$(header).attr("indeterminate", true);
									}
									else
									{
										$(header).attr("checked", true);
										$(header).removeAttr("indeterminate");
									}
								});
						}
					};
							

相关资源