Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
149299 | Nov 20,2019 11:16 PM UTC | Nov 25,2019 04:29 AM UTC | JavaScript - EJ 2 | 6 |
![]() |
Tags: MultiSelect |
var data= new DataManager({
url: 'http://localhost:56237/Home/UrlDatasource',
adaptor: new UrlAdaptor ,
crossDomain: true
}); // Making the request to server
listObj.dataSource = data; // Set the dataSource to component
listObj.dataBind(); // Call the dataBind to reflect the changes |
document.getElementById('btn').addEventListener('click',function(){
listObj.addItem({ShipCountry: 'America',CustomerID:'AMR'});
}) |
let value: string[] = ['ALFKI','ANATR','BOLID','BLONP']
// initialize MultiSelect component
let listObj: MultiSelect = new MultiSelect({
// bind the DataManager instance to dataSource property
dataSource: new DataManager({
url: 'http://localhost:56237/Home/UrlDatasource',
adaptor: new UrlAdaptor ,
crossDomain: true
}),
query: new Query().select(['ShipCountry', 'CustomerID']).take(10).addParams('additionalParams', JSON.stringify(value)),
// map the appropriate columns to fields property
fields: { text: 'ShipCountry', value: 'CustomerID' },
// set the placeholder to MultiSelect input element
placeholder: 'Select name',
// sort the resulted items
sortOrder: 'Ascending',
value: ['ALFKI','ANATR','BOLID','BLONP']
});
listObj.appendTo('#remote'); |
public JsonResult UrlDatasource([FromBody]Data dm, string additionalParams)
{
var val = OrdersDetails.GetAllRecords();
var Data = val.ToList();
var count = val.Count();
string[] splitResult = new string[] { };
if (dm.where != null)
{
Data = (from cust in Data
select cust).ToList();
}
if (additionalParams != null)
{
string[] seperators = { "[", "]", "," };
string replace = additionalParams.Replace("\"", "");
splitResult = replace.Split(seperators, StringSplitOptions.RemoveEmptyEntries);
}
if (dm.take != 0)
Data = Data.Take(dm.take).ToList();
List<OrdersDetails> filterItem = new List<OrdersDetails>();
if (splitResult.Length != 0)
{
for (var i = 0; i<splitResult.Length; i++)
{
var filter = Data.Where(j => j.CustomerID.Equals(splitResult[i])).ToList();
filterItem.Add(filter[0]);
}
}
else
{
filterItem = null;
}
return Json(filterItem);
}
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.