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>









share|improve this question






















  • 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















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>









share|improve this question






















  • 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













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>









share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Bressuire

Vorschmack

Quarantine