When triggering the pop-up browse form, this is what I see: form modal
This is the result after entering search input: result
Please assist in resolving this issue. Thank you.
Controller
In this form, I am using a partial view to call the modal form:
ViewData["CurrentFilter"] = SearchString;
var Items = new List<ExpandoObject>();
this.iFA = FA;
this.nSP = SP;
this.iFA2 = FA2;
this.isItems = isItem;
this.nSearch2 = SearchString;
dtBrowse = new DataTable();
if (iFA2==0)
{
dtBrowse = RefreshData(true);
}
else
{
dtBrowse = RefreshData(false, iFA2, TxtCategory,SearchString);
}
int i = 0;
nSP = SP;
ViewBag.iFA2 = FA2;
ViewBag.Category = AddItemToComboBox(dtBrowse);
isItems = isItem;
nSearch2 = SearchString;
return PartialView("_BrowsePartial",dtBrowse);
View
@using System.Reflection
@using System.Data
@model DataTable
<form asp-action="BrowseTrans" method="get">
<div class="modal modal-blur fade" id="modal-team" tabindex="-1" role="document" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="form">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Browse</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row mb-3 align-items-end">
<div class="col col-4 input-icon">
<input type="text" value="@ViewData["CurrentFilter"]" class="form-control" name="SearchString" placeholder="Search…">
<span class="input-icon-addon">
<!-- Download SVG icon from http://tabler-icons.io/i/search -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><circle cx="10" cy="10" r="7" /><line x1="21" y1="21" x2="15" y2="15" /></svg>
</span>
</div>
<div class="col col-2">
<label class="form-label">By Category</label>
</div>
<div class="col form-group">
<select id="ddlCurr" asp-items="@(new SelectList(ViewBag.Category, "Category", "Category"))" name="TxtCategory" class="form-control"gt;
</select>
<span class="text-danger"></span>
</div>
</div>
<div class="row mb-3 align-items-end">
<div class="table-responsive" role="grid">
<table class="table table-vcenter card-table" style="table-layout: auto; display: block; height: 350px;">
<thead>
<tr>
</tr>
<tr>
@for (int c = 0; c < Model.Columns.Count; c++)
{
<th class="w-1">@Model.Columns[c].Caption</th>
}
</tr>
</thead>
<tbody>
@foreach (DataRow dr1 in Model.Rows)
{
<tr>
@for (int c = 0; c < Model.Columns.Count; c++)
{
if (c == 0)
{
<td>
<div class="d-flex py-2 align-items-sm-baseline">
<div class="flex-fill">
<div><a href="#" class="text-reset" style="font-size: 12px;">@dr1[c].ToString()</a></div>
</div>
</div>
</td>
}
else
{
<td>
<div class="d-flex py-2 align-items-sm-baseline">
<div class="flex-fill">
<div class="text-muted"><a class="text-reset" style="font-size: 10px;">@dr1[c].ToString()</agt;<>/div>
</div>
</div>
</td>
}
}
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn me-auto" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Add Team</button>
</div>
</div>
</div>
</div>
</form>
Javascript
This JavaScript function script is used when calling the modal form:
$(function () {
var PlaceHolderElement = $('#PlaceHolderHere');
$('button[data-toggle="ajax-modal"]').click(function (event) {
var url = $(this).data('url');
$.get(url).done(function (data) {
PlaceHolderElement.html(data);
PlaceHolderElement.find('.modal').modal('show');
})
})
PlaceHolderElement.on('click', '[data-save="modal"]', function (event) {
var form = $(this).parents('.modal').find('form');
var actionUrl = form.attr('action');
var sendData = form.serialize();
$.post(actionUrl, sendData).done(function (data) {
PlaceHolderElement.find('.modal').modal('hide');
location.reload();
})
})
})