简体   繁体   English

拖放表格信息?

[英]Drag and drop table information?

I have a home page with table and a few 'favorite' folders. 我有一个带表的主页和一些“收藏夹”文件夹。 These folders are for holding 'favorite' rows of information. 这些文件夹用于保存“收藏夹”信息行。 Users drag and drop specific rows of information from the home table to the folder table. 用户将特定的信息行从主表拖放到文件夹表。 Rather than dragging the entire row (because my rows are very wide, and it can be unclear which folder you are dropping this row into), I have an icon before each case number that will ideally hold the information for said row. 而不是拖动整个行(因为我的行很宽,并且可能不清楚要将该行放入哪个文件夹),我在每个案例号之前都有一个图标,可以理想地保存该行的信息。 In this case, it's an arrow. 在这种情况下,它是一个箭头。 What I need to happen is when you drag this arrow and drop it in this folder, the information from the 'dragged row' will append to the according 'favorite' table. 我需要做的是,当您拖动该箭头并将其放到该文件夹​​中时,“已拖动行”中的信息将追加到相应的“收藏夹”表中。 This icon should disappear on drop, along with the corresponding row from the home page. 该图标与首页上的相应行一并消失。 Double clicking the folder will 'open' this folder to view favorite rows, both old and newly dropped. 双击该文件夹将“打开”此文件夹以查看收藏的行,包括旧行和新行。 Here is my fiddle 这是我的小提琴

$( ".drag" ).draggable({ revert: "invalid" });

$( ".dropTarget" ).droppable({
    drop: function( event, ui ) {
        var dropped = parseInt($(this).attr('title')) + 1;
        $( this )
            .attr('title',dropped+' entries'); 

        var delay =  $(this);
        delay.prop('disabled', true).addClass('ui-state-highlight')
        setTimeout(function() {
            delay.prop('disabled', false).removeClass('ui-state-highlight');
        }, 2000)
    }
});

$( ".dropTarget" ).dblclick(function() {
    $( ".fav1table" ).fadeIn();
    $( ".main" ).hide();
    //$(this).removeClass('glyphicon-folder-close').addClass('glyphicon-folder-open');  
});

First of all, I recommend you to change the cursor type while hovering the arrow. 首先,建议您在悬停箭头的同时更改光标类型。 This will help the user. 这将对用户有所帮助。 What you need is to determine what lines allready have been added to favorite. 您需要确定已将哪些行添加到收藏夹。 A solution can be to create two CSS classes. 一个解决方案是创建两个CSS类。 normal and favorite . normalfavorite For each line that have already been "favorized", add class favorite . 对于已经被“收藏”的每一行,添加class favorite So you will have some arrows like class="drag favorite" . 因此,您将拥有一些箭头,例如class="drag favorite" In the CSS just set "favorized" arrows as invisible or undisplayed. 在CSS中,只需将“收藏夹”箭头设置为不可见或不显示即可。

On the drop event of the .droppable() method, add the class "favorite" to the dropped arrow. .droppable()方法的drop事件上,将类“ favorite”添加到放置的箭头。 So it will be not visible anymore. 因此它将不再可见。 You can re-use this class later in a selector, to select all favorite rows for instance... 您可以稍后在选择器中重新使用此类,以选择所有喜欢的行...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM