Hi,
I'm struggling quite hard to achieve what it says in tile but it seems I have the wrong approach. What I was trying to do is to follow this example. The main problem is that it looks like that autocomplete does not load new values if I change a parameter in the second autocomplete.
For example, I have Column Customers and Column Orders. One customer can have many orders but each order belongs to only one customer (foreign key).
<ejs-grid id="PaleteGrid" load="onLoad" showColumnChooser="true" allowPaging="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel", "ColumnChooser" })" allowFiltering="true" allowSorting="true" allowPaging="true"})">
<e-grid-editsettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Normal" showDeleteConfirmDialog="true"></e-grid-editsettings>
<e-data-manager url="Palete/Index?handler=DataSource" insertUrl="Palete/Index?handler=Insert" updateUrl="Palete/Index?handler=Update" removeUrl="Palete/Index?handler=Delete" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-filterSettings type="Excel"></e-grid-filterSettings>
<e-grid-pageSettings pageCount="5" pageSize="10"></e-grid-pageSettings>
<e-grid-columns>
<e-grid-column field="Id" headerText="ID" visible="true" isidentity="true" isPrimaryKey="true" textAlign="Right" width="120"> </e-grid-column>
<e-grid-column field="Orders.Customer.Name" headerText="Customer" validationRules="@(new { required=true})" width="140" edit="@(new {create="CustomerCreate", read="CustomerRead", destroy="CustomerDestroy", write="CustomerWrite"})"></e-grid-column>
<e-grid-column field="Orders.Number" headerText="Orders" width="140" edit="@(new {create="OrdersStevilkaCreate", read="OrdersStevilkaRead", destroy="OrdersStevilkaDestroy", write="OrdersStevilkaWrite"})"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
var ObjectOrders;
var ObjectCustomer;
var ElementOrders;
var ElementCustomer;
function OrdersStevilkaCreate(args) {
// create a input element
ElementOrders = document.createElement('input');
return ElementOrders;
}
function OrdersStevilkaRead(args) {
// return the value which will be saved in the grid
return ObjectOrders.value;
}
function OrdersStevilkaDestroy() {
// destroy the custom component.
ObjectOrders.destroy();
}
function OrdersStevilkaWrite(args) {
//console.log(args);
//console.log(args.rowData);
// add multiple parameters in the Query
var query = new ej.data.Query();
query.addParams('CustomerID', args.rowData.Orders.CustomerID);
//query.addParams('OrderID', args.rowData.OrderID)
// create a autoComplete control
ObjectOrders = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteOrders',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Orders"]["Stevilka"],
//map the appropriate columns to fields property
fields: { text: 'Orders.Stevilka', value: 'Orders.Stevilka' },
//set the placeholder to DropDownList input
placeholder: "Find order",
//bind query property
query: query
});
//render the component
ObjectOrders.appendTo(ElementOrders);
}
function CustomerCreate(args) {
// create a input element
ElementCustomer = document.createElement('input');
return ElementCustomer;
}
function CustomerRead(args) {
// return the value which will be saved in the grid
return ObjectCustomer.value;
}
function CustomerDestroy() {
// destroy the custom component.
ObjectCustomer.destroy();
}
function CustomerWrite(args) {
// create a autoComplete control
ObjectCustomer = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteCustomer',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Orders"]["Customer"]["Naziv"],
//map the appropriate columns to fields property
fields: { text: 'Orders', value: 'Customer' },
//set the placeholder to DropDownList input
placeholder: "Find Customer",
change: (e) => {
console.log(e.value);
var formEle = document.getElementById("PaleteGrid").querySelector("form").ej2_instances[0];
var CustomerEle = formEle.getInputElement('Orders___Customer___Name');
var OrdersEle = formEle.getInputElement('Orders___Number');
OrdersEle.value = "";
CustomerEle.value = e.value;
}
});
//render the component
ObjectCustomer.appendTo(ElementCustomer);
</script>
What am I doing wrong?
|
function CustomerWrite(args) {
// create a autoComplete control
ObjectCustomer = new ej.dropdowns.AutoComplete({
---
change: (e) => {
console.log(e.value);
ObjectOrders.value = "dynamic text"; // change the value of AutoComplete component using its instance
}
});
//render the component
ObjectCustomer.appendTo(ElementCustomer);
}
|
|
function CustomerWrite(args) {
// create a autoComplete control
ObjectCustomer = new ej.dropdowns.AutoComplete({
----
change: (e) => {
var formEle = document.getElementById("PaleteGrid").querySelector("form").ej2_instances[0];
// get the input element
var CustomerEle = formEle.element.querySelector('#' + grid.element.id + 'Orders___Customer___Name');
CustomerEle.value = "" // change the input element value
}
});
//render the component
ObjectCustomer.appendTo(ElementCustomer);
}
|
Hi Rajapandiyan,
thank you for your help, I didn't know it was so easy. The end solution is that I needed to change the value of the additional parameter that I send to the server-side.
So the easiest way is to do this:
change: (e) => {
query.params[0].value = ElementDobavitelj.value;
},If anyone will be interested in the whole solution you can find it bellow:
var ObjectDobavnica;
var ObjectDobavitelj;
var ElementDobavnica;
var ElementDobavitelj;
function dobavnicaStevilkaCreate(args) {
// create a input element
ElementDobavnica = document.createElement('input');
return ElementDobavnica;
}
function dobavnicaStevilkaRead(args) {
// return the value which will be saved in the grid
return ObjectDobavnica.value;
}
function dobavnicaStevilkaDestroy() {
// destroy the custom component.
ObjectDobavnica.destroy();
}
function dobavnicaStevilkaWrite(args) {
//console.log(args);
//console.log(args.rowData);
// add multiple parameters in the Query
var query = new ej.data.Query();
query.addParams('DobaviteljNaziv', args.rowData.Dobavnica.Dobavitelj.Naziv);
//query.addParams('OrderID', args.rowData.OrderID)
// create a autoComplete control
ObjectDobavnica = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteDobavnica',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Dobavnica"]["Stevilka"],
//map the appropriate columns to fields property
fields: { text: 'Dobavnica.Stevilka', value: 'Dobavnica.Stevilka' },
//set the placeholder to DropDownList input
placeholder: "Najdi dobavnico",
change: (e) => {
query.params[0].value = ElementDobavitelj.value;
},
//bind query property
query: query
});
//render the component
ObjectDobavnica.appendTo(ElementDobavnica);
}
function dobaviteljCreate(args) {
// create a input element
ElementDobavitelj = document.createElement('input');
return ElementDobavitelj;
}
function dobaviteljRead(args) {
// return the value which will be saved in the grid
return ObjectDobavitelj.value;
}
function dobaviteljDestroy() {
// destroy the custom component.
ObjectDobavitelj.destroy();
}
function dobaviteljWrite(args) {
// create a autoComplete control
ObjectDobavitelj = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteDobavitelj',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Dobavnica"]["Dobavitelj"]["Naziv"],
//map the appropriate columns to fields property
fields: { text: 'Dobavnica', value: 'Dobavitelj' },
//set the placeholder to DropDownList input
placeholder: "Najdi dobavitelja",
change: (e) => {
ObjectDobavnica.value = "";
}
});
//render the component
ObjectDobavitelj.appendTo(ElementDobavitelj);
}
Basically what is done is that every time we change the value Dobavnica (delivery note), we send to the serverside current value of the field Dobavitelj (Supplier).
I was wondering if there is any documentation available regarding handling the frontside code?
Best Regards, Miha
Hi Rajapandiyan,
thank you very much for the link. This is very useful.
What I have figured out is that my solution is working only partly. If I have the name of the supplier already input, then I can autocomplete the delivery notes. Now the question which pops up is what if I don't have the Supplier field already filled, can I just choose the supplier based on the delivery note I have selected? I think this is called autofill (where you fill other columns based on the value you have selected)
I think this could be solved in two ways, but just don't have a clue on how to implement them:
|
[index.cshtml]
function OrdersStevilkaWrite(args) { ---- // create a autoComplete control ObjectOrders = new ej.dropdowns.AutoComplete({ ---- value: args.rowData["Supplier "] == undefined ? “defaultText” : args.rowData["Supplier "], ---- }); //render the component ObjectOrders.appendTo(ElementOrders); } |
Hello
Rajapandiyan,
maybe I should ask in a different way.
Is it possible to lunch a server-side query, from autocomplete change event and then bind its data to field values of column grid?
The idea is as I mentioned if I change the value of field "Dobavitelj":
Field "Dobavnica" gets cleared (this is working)
Then I'm able to select only from Dobavnica (Delivery note), which belongs to selected Dobavitelj (Customer). This is also working:
Now the question is: If I clear the field "Dobavtelj". Then I am able to choose from all delivery notes (this is working), but then when I select the "Dobavnica" (Delivery note). I want to update Dobavitelj (Customer) field with the Customer name to which the delivery note belongs.
Like I said: One Customer can have multiple delivery notes, but the delivery note can have only one customer.
So how to solve this?
Currently, I have this code on the front side:
var ObjectDobavnica;
var ObjectDobavitelj;
var ObjectMaterial;
var ElementDobavnica;
var ElementDobavitelj;
var ElementMaterial;
//create query
var queryDobavnica;
var queryDobavitelj;
function dobavnicaStevilkaCreate(args) {
// create a input element
ElementDobavnica = document.createElement('input');
return ElementDobavnica;
}
function dobavnicaStevilkaRead(args) {
// return the value which will be saved in the grid
return ObjectDobavnica.value;
}
function dobavnicaStevilkaDestroy() {
// destroy the custom component.
ObjectDobavnica.destroy();
}
function dobavnicaStevilkaWrite(args) {
// add multiple parameters in the Query
var dobaviteljNaziv;
if (args.rowData.Dobavnica.Dobavitelj.Naziv !== undefined)
dobaviteljNaziv = args.rowData.Dobavnica.Dobavitelj.Naziv;
queryDobavnica = new ej.data.Query();
queryDobavnica.addParams('DobaviteljNaziv', dobaviteljNaziv);
// create a autoComplete control
ObjectDobavnica = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteDobavnica',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Dobavnica"]["Stevilka"],
//map the appropriate columns to fields property
fields: { text: 'Dobavnica.Stevilka', value: 'Dobavnica.Stevilka' },
//set the placeholder to DropDownList input
placeholder: "Najdi dobavnico",
change: (e) => {
if (ObjectDobavitelj.value === null && ObjectDobavnica.value != null) {
queryDobavitelj.params[0].value = ObjectDobavnica.value;
}
},
//bind query property
query: queryDobavnica
});
//render the component
ObjectDobavnica.appendTo(ElementDobavnica);
}
function dobaviteljCreate(args) {
// create a input element
ElementDobavitelj = document.createElement('input');
return ElementDobavitelj;
}
function dobaviteljRead(args) {
// return the value which will be saved in the grid
return ObjectDobavitelj.value;
}
function dobaviteljDestroy() {
// destroy the custom component.
ObjectDobavitelj.destroy();
}
function dobaviteljWrite(args) {
var dobavnicaStevilka;
if (args.rowData.Dobavnica.Stevilka !== undefined)
dobavnicaStevilka = args.rowData.dobavnicaStevilka;
queryDobavitelj = new ej.data.Query();
queryDobavitelj.addParams('DobavnicaStevilka', dobavnicaStevilka);
// create a autoComplete control
ObjectDobavitelj = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteDobavitelj',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Dobavnica"]["Dobavitelj"]["Naziv"],
//map the appropriate columns to fields property
fields: { text: 'Dobavnica', value: 'Dobavitelj' },
//set the placeholder to DropDownList input
placeholder: "Najdi dobavitelja",
change: (e) => {
if (ObjectDobavitelj.value !== null) {
if (queryDobavnica.params[0].value !== ObjectDobavnica.value) {
ObjectDobavnica.value = null;
}
}
queryDobavnica.params[0].value = ElementDobavitelj.value;
},
//bind query property
query: queryDobavitelj
});
//render the component
ObjectDobavitelj.appendTo(ElementDobavitelj);
}
function materialCreate(args) {
// create a input element
ElementMaterial = document.createElement('input');
return ElementMaterial;
}
function materialRead(args) {
// return the value which will be saved in the grid
return ObjectMaterial.value;
}
function materialDestroy() {
// destroy the custom component.
ObjectMaterial.destroy();
}
function materialWrite(args) {
// create a autoComplete control
ObjectMaterial = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteMaterial',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Tip"],
//map the appropriate columns to fields property
fields: { text: 'Tip', value: 'Tip' },
//set the placeholder to DropDownList input
placeholder: "Najdi material",
});
//render the component
ObjectMaterial.appendTo(ElementMaterial);
}
|
function countryWrite(args) {
countryObj = new ej.dropdowns.AutoComplete({
dataSource: data,
fields: { value: 'ShipCountry', text: 'ShipCountry' },
change: function(){
if(countryObj.value == "" || countryObj.value == null){
stateObj.enabled = false; // disable the cascade field if have empty value
}
---
},
filtering: function(args){
if(args.text == ""){
stateObj.enabled = false;
}
},
});
countryObj.appendTo(args.element);
}
|
Hi Rajapandiyan,
I can't completely agree, that selecting from the list of Dobavnica while Dobavitelj is undefined it's an invalid case. This should be a valid case because each Dobavnica belongs to exactly one Dobavitelj.
I had got this working using jQuery you can see the gif animation of the working project attached.
bellow is the jQuery code that does this:
$(document).ready(function () {
$('#DobaviteljNaziv').autocomplete({
autoFocus: true,
source: function (request, response) {
$.ajax({
url: '/Palete/Create?handler=AutoCompleteDobavitelj',
beforeSend: function (xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
data: { "prefix": request.term },
type: "POST",
success: function (data) {
response($.map(data, function (item) {
return item;
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (event, ui) {
(document.getElementById("DobavnicaStevilka").value = "");
}
});
$('#DobavnicaStevilka').autocomplete({
autoFocus: true,
source: function (request, response) {
$.ajax({
url: '/Palete/Create?handler=AutoCompleteDobavnica',
beforeSend: function (xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
data: { "prefix": request.term, "DobaviteljNaziv": DobaviteljNaziv.value },
type: "POST",
success: function (data) {
response($.map(data, function (item) {
return item;
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (event, ui) {
if (document.getElementById("DobaviteljNaziv").value == "") {
var $form = $('form');
var data = {
'dobavnicaSt': ''
};
data.dobavnicaSt = ui.item.label;
data = $form.serialize() + '&' + $.param(data);
$.post('/Palete/Create?handler=DobavnicaSelect', data, function (msg) {
document.getElementById("DobaviteljNaziv").value = msg;
});
}
}
});
});The main part of the code which solve this case is here:
select: function (event, ui) {
if (document.getElementById("DobaviteljNaziv").value == "") {
var $form = $('form');
var data = {
'dobavnicaSt': ''
};
data.dobavnicaSt = ui.item.label;
data = $form.serialize() + '&' + $.param(data);
$.post('/Palete/Create?handler=DobavnicaSelect', data, function (msg) {
document.getElementById("DobaviteljNaziv").value = msg;
});
}
}This means that when I select Dobavnica (in your case state), I fire a new request to the serverside, to search for Dobavitelj, to which Dobavnica belongs.
I do not know if something like this is possible to do with your grid?
|
function countryWrite(args) {
countryObj = new ej.dropdowns.AutoComplete({
----
change: function(args){
// change the stateObject query based on flag variable
if(countrychangedbystate){
countrychangedbystate = false; // make the flag variable as false
} else {
---
// change the StateObj query
var tempQuery = new ej.data.Query().where('ShipCountry', 'equal', countryObj.value);
stateObj.query = tempQuery;
stateObj.text = null;
stateObj.dataBind();
}
},
---
});
}
function stateWrite(args) {
---
stateObj = new ej.dropdowns.AutoComplete({
---
change: function (args){
if(countryObj.value == null){
countrychangedbystate = true; // make the flag variable true
// change the countryObject value when it is null
countryObj.element.value = args.itemData.ShipCountry; // get the shipCountry value from autoComplete itemData
countryObj.value = args.itemData.ShipCountry;
}
},
---
});
}
|
Hi Rajapandiyan,
thank you the solution is working perfectly. If anyone needs the code there is a final code below:
front end:
var ObjectDobavnica;
var ObjectDobavitelj;
var ObjectMaterial;
var dobaviteljChangedByDobavnica = false;
function dobavnicaStevilkaCreate(args) {
// create a input element
var ElementDobavnica = document.createElement('input');
return ElementDobavnica;
}
function dobavnicaStevilkaRead(args) {
// return the value which will be saved in the grid
return ObjectDobavnica.value;
}
function dobavnicaStevilkaDestroy() {
// destroy the custom component.
ObjectDobavnica.destroy();
}
function dobavnicaStevilkaWrite(args) {
// add multiple parameters in the Query
var query = new ej.data.Query();
query.addParams('Dobavnica.Dobavitelj.Naziv', args.rowData.Dobavnica.Dobavitelj.Naziv);
query.addParams('Dobavnica.Stevilka', args.rowData.Dobavnica.Stevilka);
query.where('Dobavitelj.Naziv', 'equal', args.rowData["Dobavnica"]["Dobavitelj"]["Naziv"]);
// create a autoComplete control
ObjectDobavnica = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteDobavnica',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Dobavnica"]["Stevilka"],
//map the appropriate columns to fields property
fields: { text: 'Stevilka', value: 'Stevilka' },
//set the placeholder to DropDownList input
placeholder: "Najdi dobavnico",
floatLabelType: 'Never',
enabled: args.rowData["Dobavnica"]["Stevilka"] != undefined,
change: (e) => {
if (ObjectDobavitelj.value == null) {
dobaviteljChangedByDobavnica = true;
ObjectDobavitelj.element.value = e.itemData.Dobavitelj.Naziv;
ObjectDobavitelj.value = e.itemData.Dobavitelj.Naziv;
}
}
});
//render the component
ObjectDobavnica.appendTo(args.element);
}
function dobaviteljCreate(args) {
// create a input element
var ElementDobavitelj = document.createElement('input');
return ElementDobavitelj;
}
function dobaviteljRead(args) {
// return the value which will be saved in the grid
return ObjectDobavitelj.value;
}
function dobaviteljDestroy() {
// destroy the custom component.
ObjectDobavitelj.destroy();
}
function dobaviteljWrite(args) {
// create a autoComplete control
ObjectDobavitelj = new ej.dropdowns.AutoComplete({
//bind the data manager instance to dataSource property
dataSource: new ej.data.DataManager({
url: 'Palete/Index?handler=AutoCompleteDobavitelj',
adaptor: new ej.data.UrlAdaptor(),
headers: [{ 'XSRF-TOKEN': $("input:hidden[name=__RequestVerificationToken]").val() }],
crossDomain: true
}),
//bind the current cell value to the Dropdown which will be displayed only when the dropdown dataSource contains that value
value: args.rowData["Dobavnica"]["Dobavitelj"]["Naziv"],
//map the appropriate columns to fields property
fields: { text: 'Dobavnica', value: 'Dobavitelj' },
//set the placeholder to DropDownList input
placeholder: "Najdi dobavitelja",
change: (e) => {
if (dobaviteljChangedByDobavnica) {
dobaviteljChangedByDobavnica = false;
}
else {
if (ObjectDobavitelj.value == "" || ObjectDobavitelj.value == null) {
var tempQuery = new ej.data.Query();
ObjectDobavnica.query = tempQuery;
ObjectDobavnica.dataBind();
}
else {
var tempQuery = new ej.data.Query().where('Dobavnica.Dobavitelj.Naziv', 'Equal', ObjectDobavitelj.value)
ObjectDobavnica.query = tempQuery;
ObjectDobavnica.text = null;
ObjectDobavnica.dataBind();
}
}
}
});
//render the component
ObjectDobavitelj.appendTo(args.element);
}
server-side:
public async Task<JsonResult> OnPostAutoCompleteDobavnicaAsync([FromBody] Data dm)
{
var Data = await _context.Dobavnica
.Include(d => d.Dobavitelj)
.Take(dm.take)
.OrderByDescending(d => d.Datum)
.ToListAsync();
if (dm.where != null)
{
if (dm.where.Count > 1 && dm.@where[1].value != null)
{
if(dm.where[0].field == "Dobavnica.Dobavitelj.Naziv" && dm.where[1].field == "Stevilka")
{
Data = await _context.Dobavnica
.Include(d => d.Dobavitelj)
.Where(d => d.Dobavitelj.Naziv.Contains(dm.@where[0].value.ToString().ToLower()) && d.Stevilka.Contains(dm.@where[1].value.ToString().ToLower()))
.Take(dm.take)
.OrderByDescending(d => d.Datum)
.ToListAsync();
}
}
else if(dm.@where[0].value != null)
{
if(dm.where[0].field == "Stevilka")
{
Data = await _context.Dobavnica
.Include(d => d.Dobavitelj)
.Where(d => d.Stevilka.Contains(dm.@where[0].value.ToString().ToLower()))
.Take(dm.take)
.OrderByDescending(d => d.Datum)
.ToListAsync();
}
}
}
return new JsonResult(Data);
}
I was also wondering if you could explain this code please:
// add multiple parameters in the Query
var query = new ej.data.Query();
query.addParams('Dobavnica.Dobavitelj.Naziv', args.rowData.Dobavnica.Dobavitelj.Naziv);
query.addParams('Dobavnica.Stevilka', args.rowData.Dobavnica.Stevilka);
query.where('Dobavitelj.Naziv', 'equal', args.rowData["Dobavnica"]["Dobavitelj"]["Naziv"]);
Thank you again.