A solution's to the problem's related to Web Technologies like ASP.Net, Angular Js, WebApi,Python & Other Open Source Technologies.
Saturday, November 16, 2019
Saturday, January 26, 2019
Paging, search & sorting using the datatable.js library
For implementing paging,search & sorting using the datatable.js library.
<link
rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
<table
id="table_id" class="display">
<thead>
<tr>
<th>Name</th>
<th>DOB</th>
</tr>
</thead>
<tbody>
<tr>
<td>Amar</td>
<td>10-10-2010</td>
</tr>
<tr>
<td>Akbar</td>
<td>20-11-2010</td>
</tr>
</tbody>
</table>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<script>
$(document).ready(function () {
$('#table_id').DataTable();
});
</script>
Jquery UI Multiple Search MVC
For creating autocomplete
multiple select using the jquery UI plugin.
<link
rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<label>Search fruits:</label>
<input
type="text" id="txtFruits" name="txtFruits" />
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$("#txtFruits")
.on("keydown", function (event) {
if (event.keyCode ===
$.ui.keyCode.TAB &&
$(this).autocomplete("instance").menu.active) {
event.preventDefault();
}
})
.autocomplete({
source: function (request, response) {
$.getJSON('@Url.Action("data")', {
term:
extractLast(request.term)
}, response);
},
focus: function () {
// prevent value inserted on focus
return false;
},
select: function (event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the
comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
return false;
}
});
})
</script>
/// <summary>
/// Inside the controller
/// Don't change the parameter
name (term) it's default by jquery ui
/// </summary>
public ActionResult
data(string term)
{
var
items = new[] { "Apple", "Pear", "Banana", "Pineapple", "Peach" };
var
filteredItems = items.Where(item => item.IndexOf(term, StringComparison.InvariantCultureIgnoreCase)
>= 0 );
return Json(filteredItems, JsonRequestBehavior.AllowGet);
}
Jquery UI search (autocomplete) MVC
For creating a search bar like google we can use the jquery UI plugin.
<link
rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<label>Search fruits:</label>
<input
type="text" id="txtFruits" name="txtFruits" />
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$('#txtFruits').autocomplete({
source: '@Url.Action("data")'
});
})
</script>
// <summary>
/// Inside the controller
/// Don't change the parameter
name (term) it's default by jquery ui
/// </summary>
public ActionResult
data(string term)
{
var
items = new[] { "Apple", "Pear", "Banana", "Pineapple", "Peach" };
var
filteredItems = items.Where(item => item.IndexOf(term, StringComparison.InvariantCultureIgnoreCase)
>= 0 );
return Json(filteredItems, JsonRequestBehavior.AllowGet);
}
Subscribe to:
Posts (Atom)
Git Commands
Git Version To check the git version Git -v Git Clone To clone the repository, use the following command: Git clone [u...
-
Below are the steps to deploy the Django application on XAMPP apache server. Assuming that you have already downloaded and installed the...
-
using MongoDB.Bson; using MongoDB.Driver; static MongoClient client = new MongoClie...
-
Git Version To check the git version Git -v Git Clone To clone the repository, use the following command: Git clone [u...