No matches found - ASP.NET MVC jquery autocomplet
up vote
0
down vote
favorite
I have an Autocomplet textbox for my search and when i try Search efter something it give No matches found
.i also debugged and i can see value will pass to controller.did i miss something ! Can anyone please help me or point me in to the right direction.
thanks in advance :)
Contoller:
public ActionResult Sp(string searchString) {
string EmailID = Session["Email"].ToString();
var v = (from cbr in db.Contact_Business_Relation
join c in db.Contact on cbr.Contact_No_ equals c.Company_No_
join sa in db.Sales_Invoice_Header on cbr.No_ equals sa.Sell_to_Customer_No_
join sih in db.Sales_Invoice_Line on sa.No_ equals sih.Document_No_
where c.E_Mail == EmailID
&&
sih.Type == 2
select new ClosedOrders
{
SalesInvoiceQuantity = db.Sales_Invoice_Line.Where(l => l.Document_No_ == sa.No_).Select(l => l.Quantity).DefaultIfEmpty(0).Sum(),
CreatedDate = sa.Posting_Date,
DeliveryAddress = sa.Ship_to_Address + ", " + sa.Ship_to_Post_Code + " " + sa.Ship_to_City + ", " + sa.Ship_to_Country_Region_Code,
Reference = sa.External_Document_No_,
OrderNumber = sa.Order_No_,
Fakturanummer = sa.No_,
Total = 0,
AntalAfsendteVarer = 0,
AntalVarer = 0,
varnummer = db.Item_Ledger_Entry.Where(s => s.Item_No_ == sih.No_).Select(s => s.Item_No_).Distinct().ToList(),
SerialNoInvoiceOrdrelineDeliveryCloses = db.Item_Ledger_Entry.Where(s => s.Item_No_ == sih.No_ && s.Entry_Type == 1 && s.Source_Type == 1 && s.Document_Type == 1).Select(s => s.Serial_No_).Distinct().ToList()
});
if (!String.IsNullOrEmpty(searchString))
{
v = v.Where(s => s.Fakturanummer.Contains(searchString));
}
if (!String.IsNullOrEmpty(searchString))
{
v = v.Where(s => s.varnummer.Contains(searchString));
}
return Json(v, JsonRequestBehavior.AllowGet);
JavaScript:
<div>
<label>Search</label>
<input id="searchInput" />
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$("#searchInput").autocomplete({
source: function (request, response) {
$.ajax({
url: '@Url.Action("Sp","Account")',
dataType: "json",
data: { searchString: $("#searchInput").val() },
success: function (data) {
if (!data.length) {
var result = [
{
label: 'No matches found',
value: response.term
}
];
response(result);
}
else {
// normal response
response($.map(data, function (item) {
return {
label: item.varnummer,
value: item.varnummer
}
}));
}
},
error: function (xhr, status, error) {
alert("Error");
}
});
}
});
</script>
jquery asp.net-mvc jquery-ui-autocomplete
add a comment |
up vote
0
down vote
favorite
I have an Autocomplet textbox for my search and when i try Search efter something it give No matches found
.i also debugged and i can see value will pass to controller.did i miss something ! Can anyone please help me or point me in to the right direction.
thanks in advance :)
Contoller:
public ActionResult Sp(string searchString) {
string EmailID = Session["Email"].ToString();
var v = (from cbr in db.Contact_Business_Relation
join c in db.Contact on cbr.Contact_No_ equals c.Company_No_
join sa in db.Sales_Invoice_Header on cbr.No_ equals sa.Sell_to_Customer_No_
join sih in db.Sales_Invoice_Line on sa.No_ equals sih.Document_No_
where c.E_Mail == EmailID
&&
sih.Type == 2
select new ClosedOrders
{
SalesInvoiceQuantity = db.Sales_Invoice_Line.Where(l => l.Document_No_ == sa.No_).Select(l => l.Quantity).DefaultIfEmpty(0).Sum(),
CreatedDate = sa.Posting_Date,
DeliveryAddress = sa.Ship_to_Address + ", " + sa.Ship_to_Post_Code + " " + sa.Ship_to_City + ", " + sa.Ship_to_Country_Region_Code,
Reference = sa.External_Document_No_,
OrderNumber = sa.Order_No_,
Fakturanummer = sa.No_,
Total = 0,
AntalAfsendteVarer = 0,
AntalVarer = 0,
varnummer = db.Item_Ledger_Entry.Where(s => s.Item_No_ == sih.No_).Select(s => s.Item_No_).Distinct().ToList(),
SerialNoInvoiceOrdrelineDeliveryCloses = db.Item_Ledger_Entry.Where(s => s.Item_No_ == sih.No_ && s.Entry_Type == 1 && s.Source_Type == 1 && s.Document_Type == 1).Select(s => s.Serial_No_).Distinct().ToList()
});
if (!String.IsNullOrEmpty(searchString))
{
v = v.Where(s => s.Fakturanummer.Contains(searchString));
}
if (!String.IsNullOrEmpty(searchString))
{
v = v.Where(s => s.varnummer.Contains(searchString));
}
return Json(v, JsonRequestBehavior.AllowGet);
JavaScript:
<div>
<label>Search</label>
<input id="searchInput" />
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$("#searchInput").autocomplete({
source: function (request, response) {
$.ajax({
url: '@Url.Action("Sp","Account")',
dataType: "json",
data: { searchString: $("#searchInput").val() },
success: function (data) {
if (!data.length) {
var result = [
{
label: 'No matches found',
value: response.term
}
];
response(result);
}
else {
// normal response
response($.map(data, function (item) {
return {
label: item.varnummer,
value: item.varnummer
}
}));
}
},
error: function (xhr, status, error) {
alert("Error");
}
});
}
});
</script>
jquery asp.net-mvc jquery-ui-autocomplete
Write unit tests for both server and client code
– Aluan Haddad
Nov 10 at 19:18
Where exactly the problem is? Does the controller return anything, or the problem is on the client side?
– Восилей
Nov 10 at 23:48
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an Autocomplet textbox for my search and when i try Search efter something it give No matches found
.i also debugged and i can see value will pass to controller.did i miss something ! Can anyone please help me or point me in to the right direction.
thanks in advance :)
Contoller:
public ActionResult Sp(string searchString) {
string EmailID = Session["Email"].ToString();
var v = (from cbr in db.Contact_Business_Relation
join c in db.Contact on cbr.Contact_No_ equals c.Company_No_
join sa in db.Sales_Invoice_Header on cbr.No_ equals sa.Sell_to_Customer_No_
join sih in db.Sales_Invoice_Line on sa.No_ equals sih.Document_No_
where c.E_Mail == EmailID
&&
sih.Type == 2
select new ClosedOrders
{
SalesInvoiceQuantity = db.Sales_Invoice_Line.Where(l => l.Document_No_ == sa.No_).Select(l => l.Quantity).DefaultIfEmpty(0).Sum(),
CreatedDate = sa.Posting_Date,
DeliveryAddress = sa.Ship_to_Address + ", " + sa.Ship_to_Post_Code + " " + sa.Ship_to_City + ", " + sa.Ship_to_Country_Region_Code,
Reference = sa.External_Document_No_,
OrderNumber = sa.Order_No_,
Fakturanummer = sa.No_,
Total = 0,
AntalAfsendteVarer = 0,
AntalVarer = 0,
varnummer = db.Item_Ledger_Entry.Where(s => s.Item_No_ == sih.No_).Select(s => s.Item_No_).Distinct().ToList(),
SerialNoInvoiceOrdrelineDeliveryCloses = db.Item_Ledger_Entry.Where(s => s.Item_No_ == sih.No_ && s.Entry_Type == 1 && s.Source_Type == 1 && s.Document_Type == 1).Select(s => s.Serial_No_).Distinct().ToList()
});
if (!String.IsNullOrEmpty(searchString))
{
v = v.Where(s => s.Fakturanummer.Contains(searchString));
}
if (!String.IsNullOrEmpty(searchString))
{
v = v.Where(s => s.varnummer.Contains(searchString));
}
return Json(v, JsonRequestBehavior.AllowGet);
JavaScript:
<div>
<label>Search</label>
<input id="searchInput" />
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$("#searchInput").autocomplete({
source: function (request, response) {
$.ajax({
url: '@Url.Action("Sp","Account")',
dataType: "json",
data: { searchString: $("#searchInput").val() },
success: function (data) {
if (!data.length) {
var result = [
{
label: 'No matches found',
value: response.term
}
];
response(result);
}
else {
// normal response
response($.map(data, function (item) {
return {
label: item.varnummer,
value: item.varnummer
}
}));
}
},
error: function (xhr, status, error) {
alert("Error");
}
});
}
});
</script>
jquery asp.net-mvc jquery-ui-autocomplete
I have an Autocomplet textbox for my search and when i try Search efter something it give No matches found
.i also debugged and i can see value will pass to controller.did i miss something ! Can anyone please help me or point me in to the right direction.
thanks in advance :)
Contoller:
public ActionResult Sp(string searchString) {
string EmailID = Session["Email"].ToString();
var v = (from cbr in db.Contact_Business_Relation
join c in db.Contact on cbr.Contact_No_ equals c.Company_No_
join sa in db.Sales_Invoice_Header on cbr.No_ equals sa.Sell_to_Customer_No_
join sih in db.Sales_Invoice_Line on sa.No_ equals sih.Document_No_
where c.E_Mail == EmailID
&&
sih.Type == 2
select new ClosedOrders
{
SalesInvoiceQuantity = db.Sales_Invoice_Line.Where(l => l.Document_No_ == sa.No_).Select(l => l.Quantity).DefaultIfEmpty(0).Sum(),
CreatedDate = sa.Posting_Date,
DeliveryAddress = sa.Ship_to_Address + ", " + sa.Ship_to_Post_Code + " " + sa.Ship_to_City + ", " + sa.Ship_to_Country_Region_Code,
Reference = sa.External_Document_No_,
OrderNumber = sa.Order_No_,
Fakturanummer = sa.No_,
Total = 0,
AntalAfsendteVarer = 0,
AntalVarer = 0,
varnummer = db.Item_Ledger_Entry.Where(s => s.Item_No_ == sih.No_).Select(s => s.Item_No_).Distinct().ToList(),
SerialNoInvoiceOrdrelineDeliveryCloses = db.Item_Ledger_Entry.Where(s => s.Item_No_ == sih.No_ && s.Entry_Type == 1 && s.Source_Type == 1 && s.Document_Type == 1).Select(s => s.Serial_No_).Distinct().ToList()
});
if (!String.IsNullOrEmpty(searchString))
{
v = v.Where(s => s.Fakturanummer.Contains(searchString));
}
if (!String.IsNullOrEmpty(searchString))
{
v = v.Where(s => s.varnummer.Contains(searchString));
}
return Json(v, JsonRequestBehavior.AllowGet);
JavaScript:
<div>
<label>Search</label>
<input id="searchInput" />
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$("#searchInput").autocomplete({
source: function (request, response) {
$.ajax({
url: '@Url.Action("Sp","Account")',
dataType: "json",
data: { searchString: $("#searchInput").val() },
success: function (data) {
if (!data.length) {
var result = [
{
label: 'No matches found',
value: response.term
}
];
response(result);
}
else {
// normal response
response($.map(data, function (item) {
return {
label: item.varnummer,
value: item.varnummer
}
}));
}
},
error: function (xhr, status, error) {
alert("Error");
}
});
}
});
</script>
jquery asp.net-mvc jquery-ui-autocomplete
jquery asp.net-mvc jquery-ui-autocomplete
asked Nov 10 at 19:09
The First
335
335
Write unit tests for both server and client code
– Aluan Haddad
Nov 10 at 19:18
Where exactly the problem is? Does the controller return anything, or the problem is on the client side?
– Восилей
Nov 10 at 23:48
add a comment |
Write unit tests for both server and client code
– Aluan Haddad
Nov 10 at 19:18
Where exactly the problem is? Does the controller return anything, or the problem is on the client side?
– Восилей
Nov 10 at 23:48
Write unit tests for both server and client code
– Aluan Haddad
Nov 10 at 19:18
Write unit tests for both server and client code
– Aluan Haddad
Nov 10 at 19:18
Where exactly the problem is? Does the controller return anything, or the problem is on the client side?
– Восилей
Nov 10 at 23:48
Where exactly the problem is? Does the controller return anything, or the problem is on the client side?
– Восилей
Nov 10 at 23:48
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242484%2fno-matches-found-asp-net-mvc-jquery-autocomplet%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Write unit tests for both server and client code
– Aluan Haddad
Nov 10 at 19:18
Where exactly the problem is? Does the controller return anything, or the problem is on the client side?
– Восилей
Nov 10 at 23:48