欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net+jquery Gridview的多行拖放, 以及跨控件拖放

 更新時間:2009年11月13日 21:19:04   作者:  
學(xué)習(xí)JQuery時,發(fā)現(xiàn)JQuery只能做單行拖放, 于是花時間做了一個多行拖放的例子, 以備以后使用。
復(fù)制代碼 代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="jquery-ui-1.7.2.custom.js"></script>
<script type="text/javascript">
//===================================
//dragg and drop sample program
//authored by gujinsong@trans-cosmos
//2009-11-11
//===================================
//temporary var that stored selected rows
var SelectedRows = [];
//forbid all select
document.onselectstart = function() { return false; }
//fires when dragg object go out the source table
$(document).mouseup(function() {
$(".float").hide();
$(".float")[0].innerHTML = "";
IsDragging = false;
}
).mousemove(function(e) {
if (IsDragging == true) {
$(".float").css("top", e.clientY + 2);
$(".float").css("left", e.clientX + 2);
$(".float").show();
}
});
// flag that indicates whether is during dragging
var IsDragging = false;
//using jquery give mouse event to each rows
$(document).ready(function() {
$(".stripe tr").mousedown(
function(e) {
if (this.innerHTML.substring(0, 3) == "<TH") return false;
if (!e) var e = window.event;
if (!e.ctrlKey) {
unselectAll();
}
if ($(this).context.className == "over") {
$(this).removeClass("over");
unselect();
}
else {
$(this).addClass("over");
SelectedRows.push($(this));
//set style
$(".float").css("top", e.clientY + 5);
$(".float").css("left", e.clientX + 5);
$(".float").css("zIndex", 1);
$(".float").css("position", "absolute");
$(".float").width($(this).width());
$(".float").height($(this).height() * SelectedRows.length);
for (var i = 0; i < SelectedRows.length; i++) {
$(".float").append(SelectedRows[i].clone());
}
$(".float").wrapInner("<table></table>");
}
}
).mouseup(function() {
if (this.innerHTML.substring(0, 3) == "<TH") {
$(".float").fadeOut("normal");
$(".float")[0].innerHTML = "";
IsDragging = false;
} ;
if ($(this).context.className != "over" && IsDragging == 1) {
DraggStop($(this));
}
}).mousemove(function(e) {
if (this.innerHTML.substring(0, 3) == "<TH") return false;
if (e.button == 1) {
IsDragging = true;
$(".float").css("top", e.clientY + 2);
$(".float").css("left", e.clientX + 2);
$(".float").fadeIn("normal"); //show();
}
})
});
// function that re-sort rows
function DraggStop(item) {
$(".stripe tr").each(function() {
if (this.className == "over") {
$(this).insertBefore(item);
}
});
}
//clear all selected rows
function unselectAll() {
for (var i = SelectedRows.length-1; i > -1; i--)
{
SelectedRows[i].removeClass("over");
SelectedRows.pop(i);
}
}
//un-select current row
function unselect() {
for (var i = SelectedRows.length-1; i > -1; i--)
{
if (SelectedRows[i].context.className != "over") {
SelectedRows[i].removeClass("over");
SelectedRows.pop(i);
}
}
}
//acceptable control's mouse event
function Dropable(e) {
if (IsDragging == true) {
var txt = document.getElementById("TextBox1")
txt.value = "";
$(".stripe tr").each(function() {
if (this.className == "over") {
txt.value = txt.value + this.innerHTML + "\r\n";
}
});
}
}
</script>
<style type="text/css">
th
{
background: #0066FF;
color: #FFFFFF;
line-height: 20px;
height: 30px;
}
td
{
padding: 6px 11px;
border-bottom: 1px solid #95bce2;
vertical-align: top;
text-align: center;
}
td *
{
padding: 6px 11px;
}
tr.alt td
{
background: #ecf6fc; /*這行將給所有的tr加上背景色*/
}
tr.over td
{
background: #bcd4ec; /*這個將是鼠標(biāo)高亮行的背景色*/
}
</style>
</head>
<body>
<div class="float">
</div>
<form id="form1" runat="server">
<asp:GridView ID="selectable" runat="server" class="stripe">
</asp:GridView>
<asp:TextBox ID="TextBox1" runat="server" onmouseover="Dropable();"
Height="210px" TextMode="MultiLine" Width="772px" ></asp:TextBox>
</form>
</body>
</html>

相關(guān)文章

  • asp.net中ADO SQL數(shù)據(jù)庫 筆記匯總 持續(xù)更新中

    asp.net中ADO SQL數(shù)據(jù)庫 筆記匯總 持續(xù)更新中

    asp.net中ADO SQL數(shù)據(jù)庫 筆記匯總 持續(xù)更新中,需要的朋友可以參考下
    2012-07-07
  • ASP.NET2.0緩存(Cache)技術(shù)深入理解

    ASP.NET2.0緩存(Cache)技術(shù)深入理解

    緩存技術(shù)是ASP.NET2.0非常重要的一個特性,它提供了一種非常好的本地數(shù)據(jù)緩存機(jī)制,從而有效的提高數(shù)據(jù)訪問的性能
    2012-11-11
  • Asp.net webForm設(shè)置允許表單提交Html的方法

    Asp.net webForm設(shè)置允許表單提交Html的方法

    下面小編就為大家分享一篇Asp.net webForm設(shè)置允許表單提交Html的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2017-12-12
  • .NET使用System.Timers.Timer類實現(xiàn)程序定時執(zhí)行

    .NET使用System.Timers.Timer類實現(xiàn)程序定時執(zhí)行

    這篇文章介紹了.NET使用System.Timers.Timer類實現(xiàn)程序定時執(zhí)行的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-07-07
  • ASP.NET泛型三之使用協(xié)變和逆變實現(xiàn)類型轉(zhuǎn)換

    ASP.NET泛型三之使用協(xié)變和逆變實現(xiàn)類型轉(zhuǎn)換

    這篇文章介紹了ASP.NET使用協(xié)變和逆變實現(xiàn)泛型類型轉(zhuǎn)換的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-08-08
  • ASP.NET Core中的Http緩存使用

    ASP.NET Core中的Http緩存使用

    這篇文章主要介紹了ASP.NET Core中的Http緩存使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-03-03
  • asp.net實現(xiàn)md5加密

    asp.net實現(xiàn)md5加密

    MD5加密簡單的說就是把一段明文 通過某種運算方式 求出密文。在ASP.NET中MD5的加密方式很簡單,詳細(xì)介紹看下文
    2014-03-03
  • CheckBox控件默認(rèn)選中,提交時永遠(yuǎn)獲得選中狀態(tài)的實現(xiàn)代碼

    CheckBox控件默認(rèn)選中,提交時永遠(yuǎn)獲得選中狀態(tài)的實現(xiàn)代碼

    下面小編就為大家?guī)硪黄狢heckBox控件默認(rèn)選中,提交時永遠(yuǎn)獲得選中狀態(tài)的實現(xiàn)代碼。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-05-05
  • 壓力測試中需要掌握的幾個基本概念

    壓力測試中需要掌握的幾個基本概念

    一個asp.net的頁面。對于壓力測試,必須時時刻刻做,如果不知道自己的應(yīng)用能夠承載多少的并發(fā)用戶數(shù),那基本上就是在扔定時炸彈
    2011-09-09
  • asp.net CommunityServer中的wwwStatus

    asp.net CommunityServer中的wwwStatus

    最近不得不對這個論壇進(jìn)行研究,以適應(yīng)后面的發(fā)展,現(xiàn)在同事研究太吃力了,以后改些東西,估計又要...打開web項目中的communityserver.config發(fā)現(xiàn)一個有趣的地方。
    2009-03-03

最新評論