2012-03-23 85 views
0

我正在使用MVC 3,EF Model First在我的項目上。使用Jquery和MVC3將表中的選定行添加到另一個表中

在我的看法我有4個看起來很喜歡這些的表。

<div class="questionsForSubjectType"> 
      <table> 
       <thead> 
        <tr> 
        <th> 
         Title 
        </th> 
        </tr> 
       </thead> 
       <tbody> 
        <tr> 
         <td> 
         test 
        </td> 
        </tr> 
       </tbody> 
      </table>   
</div>  

用戶應該能夠選擇並添加到另一個表讓說該表如下:

<table id="CustomPickedQuestions> 


    /* <----- Questions that users chose from the other tables /* 

    </table> 

我所尋找的是,當一個用戶在一排點擊,該行應被刪除並添加到CustomPickedQuestions,當該行被添加到該表時,用戶也應該能夠從CustomPickedQuestionsTable中刪除它,然後該行將返回到之前的Table

我現在想知道如何在客戶端jquery腳本的幫助下完成此任務。

+0

是否要執行如下操作:http://jqueryui.com/demos/droppable/#shopping-cart? – Artem 2012-03-23 14:25:06

+0

嗯,我正在尋找一些更有用的功能,就像我上面解釋過的。後來它也假設能夠刪除自定義的問題。 – Obsivus 2012-03-23 14:32:02

+0

那麼,只需用jquery克隆克隆dom對象,然後追加jquery append,像'$(「。questionsForSubjectType tr」)。click(function(){$(this).clone()。appendTo(「#CustomPickedQuestions tbody「)}); ' - 當行點擊它將被複制到目標表 – Artem 2012-03-23 14:36:49

回答

0

您的代碼中存在太多不相關的複雜問題(針對您提出的具體問題)。標題很好,但不是代碼。使用最少量的代碼/方法/屬性(使用通用名稱,即產品ID,產品名稱等),而不是發佈複雜的項目代碼,儘可能簡單地再現問題。我的教程的第3部分展示瞭如何做到這一點。請參閱http://www.asp.net/mvc/tutorials/javascript/working-with-the-dropdownlist-box-and-jquery/adding-a-new-category-to-the-dropdownlist-using-jquery-ui

+0

感謝您的通知我已經做了一個編輯 – Obsivus 2012-03-23 16:17:18

相關問題