我在哪里可以找到控制器操作或视图上的搜索输入文本框?

问题描述 投票:0回答:1

我正在使用 csharp 开发 asp.net mvc 应用程序。我遇到问题,找不到控件搜索输入类型文本框。

我在操作控制器 PendingRequests 上搜索,但找不到它。

我也在index.html上搜索它不存在

那么如何获取搜索文本框?

动作控制器

       public ActionResult Index(string filenumber)
    {
        int employeeFileNo;
        string userRole;

      
        if (!string.IsNullOrEmpty(filenumber))
        {
          
            if (int.TryParse(filenumber, out employeeFileNo))
            {
                JDEUtility jde = new JDEUtility();
                userRole = Workforce.GetUserRole(employeeFileNo);

                if (!string.IsNullOrEmpty(userRole))
                {
                    var EmpName = jde.GetEmployeeName(employeeFileNo);

                    Session[SessionKeys.UserCode] = employeeFileNo;
                    Session[SessionKeys.Username] = EmpName;
                    Session[SessionKeys.RoleCode] = userRole;
                    if (userRole != RoleKey.REQ)
                        return RedirectToAction("PendingRequests", "WorkforceRequests", null);
                    else
                        return RedirectToAction("MyRequests", "WorkforceRequests", null);
                }
                else
                    ViewBag.errorMsg = "unauthorized user";

            }
            else
            {
                ViewBag.errorMsg = "incorrect file no";
            }
        }
        else
        {
            ViewBag.errorMsg = "unauthorized user";
        }

        return View();
    }

待处理请求视图

@model IEnumerable<HR.WorkforceRequisition.Models.WorkforceRequest>

@{
    ViewBag.Title = "Pending Requests";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Pending Requests</h2>
<hr />
@if (!string.IsNullOrWhiteSpace(ViewBag.msg))
{
    <div class="alert alert-success">
        @ViewBag.msg
    </div>
}
@if (!string.IsNullOrWhiteSpace(ViewBag.errorMsg))
{
    <div class="alert alert-danger">
        @ViewBag.errorMsg
    </div>
}
<table id="dtbl" class="table table-bordered table-hover table-striped">
    <thead>
        <tr>
            <th></th>
            <th>
                @Html.DisplayNameFor(model => model.WorkforceRequestID)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.DepartmentCode)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Section)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.RequiredPosition)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.JobTitle)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.ReportingTo)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.NationalityCategory)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.StatusRemark)
            </th>
            <th>
                Requestor
            </th>
        </tr>
    </thead>

    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.ActionLink("Details", "Details", new { id = item.WorkforceRequestID })
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.WorkforceRequestID)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DepartmentCode)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Section)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.RequiredPosition)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.JobTitle)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ReportingTo)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.NationalityCategory)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.StatusRemark)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.CreatedByName)
                </td>
            </tr>
        }
    </tbody>

</table>



<script>
        $(document).ready(function () {
            $('#dtbl').DataTable({
                "scrollX": true,
                "pageLength": 10,
                dom: 'Bfrtip',
                buttons: [
                    'copy', 'csv', 'excel'
                ]
            });
        });
</script>

在哪个地方输入搜索文本框找到了预期的结果

display text box on pending requests

c# asp.net-mvc routes
1个回答
0
投票

从屏幕截图来看,您似乎需要在数据表中搜索文本框。搜索框默认显示,除非您将任何属性设置为不显示。使用您的js,我可以看到搜索框您也可以尝试将“searching”:true属性添加到您的数据表中。您可以查看文档这里。 这是一个工作片段

$(document).ready(function () {
            $('#tableID').DataTable({
          // Enable the searching
                // of the DataTable
                searching: true // will work without this also
            });
        });
<!-- jQuery -->
    <script type="text/javascript" 
        src="https://code.jquery.com/jquery-3.5.1.js">
    </script>
  
    <!-- DataTables CSS -->
    <link rel="stylesheet" href=
"https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css">
  
    <!-- DataTables JS -->
    <script src=
"https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js">
    </script>
 <table id="tableID" class="display">
        <thead>
            <tr>
                <th>ID</th>
                <th>Name</th>
                <th>Age</th>
            </tr>
        </thead>
          
        <tbody>
            <tr>
                <td>1</td>
                <td>Samer</td>
                <td>35</td>
            </tr>
            <tr>
                <td>2</td>
                <td>Rajiv</td>
                <td>30</td>
            </tr>
            <tr>
                <td>3</td>
                <td>Suhail</td>
                <td>45</td>
            </tr>
            <tr>
                <td>4</td>
                <td>Manisha</td>
                <td>4</td>
            </tr>
            <tr>
                <td>5</td>
                <td>Robbert</td>
                <td>68</td>
            </tr>
            <tr>
                <td>6</td>
                <td>Mike</td>
                <td>25</td>
            </tr>
            <tr>
                <td>7</td>
                <td>Ere</td>
                <td>23</td>
            </tr>
            <tr>
                <td>8</td>
                <td>James</td>
                <td>35</td>
            </tr>
            <tr>
                <td>9</td>
                <td>Walt</td>
                <td>65</td>
            </tr>
            <tr>
                <td>10</td>
                <td>Jessieca</td>
                <td>28</td>
            </tr>
            <tr>
                <td>11</td>
                <td>Raghu</td>
                <td>20</td>
            </tr>
        </tbody>
    </table>

© www.soinside.com 2019 - 2024. All rights reserved.