在MVC中设置多选下拉菜单的选定值

时间:2019-09-20 20:40:16

标签: javascript jquery model-view-controller multi-select

我的视图中有一个多选下拉菜单,我想显示下拉菜单中已选择并提交的所选项目。这是html代码。

package com.turquoise.jeebalalhasanat;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.github.barteksc.pdfviewer.PDFView;
import com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener;
import com.github.barteksc.pdfviewer.listener.OnPageChangeListener;
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle;
import com.shockwave.pdfium.PdfDocument;
import java.util.List;

public class ReadingActivity extends Activity implements OnPageChangeListener,OnLoadCompleteListener {

    private static final String TAG = ReadingActivity.class.getSimpleName();
    public static final String PDF_FILE = "my_book.pdf";

    PDFView pdfView ;
    Integer pageNumber;
    String pdfFileName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reading);

        pdfView = (PDFView)findViewById(R.id.pdfView);
        displayFromAsset(PDF_FILE);
    }

    private void displayFromAsset(String assetFileName) {
        pdfFileName = assetFileName;

        pdfView.fromAsset(PDF_FILE)
                .defaultPage(pageNumber)
                .enableSwipe(true)
                .swipeHorizontal(false)
                .onPageChange(this)
                .enableAnnotationRendering(true)
                .onLoad(this)
                .scrollHandle(new DefaultScrollHandle(this))
                .load();
        }

    @Override
    public void onPageChanged(int page, int pageCount) {

        pageNumber = page;
        setTitle(String.format("%s %s / %s", pdfFileName, page + 1, pageCount));

    }

    @Override
    public void loadComplete(int nbPages) {
        PdfDocument.Meta meta = pdfView.getDocumentMeta();
        printBookmarksTree(pdfView.getTableOfContents(), "-");

    }

    public void printBookmarksTree(List<PdfDocument.Bookmark> tree, String sep) {
        for (PdfDocument.Bookmark b : tree) {

            Log.e(TAG, String.format("%s %s, p %d", sep, b.getTitle(), b.getPageIdx()));

            if (b.hasChildren()) {
                printBookmarksTree(b.getChildren(), sep + "-");
            }
        }
    }

我正在使用jquery多重选择库在下拉列表中实现多个选择。我想在读取操作中查看所选的值。

               <label>Submitter</label><br />
                <select id="SelectedSubmitterIDs" name="SelectedSubmitterIDs" class="SubmitterIDClass" multiple>
                    @foreach (var data in Model.Submitters)
                    {
                        <option value="@data.Value">@data.Text</option>
                    }
                </select>

1 个答案:

答案 0 :(得分:0)

经过一些研究,将Html剃须刀Listbox调整为我工作- https://forums.asp.net/t/1778536.aspx?Loading+Multiselect+Listboxfor+in+MVC3+Razor

 <label>Submitter</label><br />
 @Html.ListBoxFor(m => m.SelectedSubmitterIDs, new MultiSelectList(Model.Submitters, "Value", "Text"), new { @multiple = "multiple" })

这些下拉列表显示了从各自数据源中选择的值-例如模型提交者。希望这可以帮助面临类似情况的其他人。谢谢

multiple select