flexigrid Ajax Filter by using flexOptions - flexigrid

I have a page data load in flexigrid, after loading there are several filters, onchange filter i try to reload the grid like this
var data = {name: 'fltr_county', value: $("#fltr_county").val(), name: 'county_ene', value:$("#county_ene").val()}
$('.flexme').flexOptions({params: [ data ]}).flexReload();
But got only 'page=1&rp=25&sortname=Borrower&sortorder=asc&query=&qtype=&county_ene=equal' posting array. Only last param value got.
How i can pass more filter in posting array?
Please help.
Thanks in advance

Im new to Flexigrid.. but faced same situation and used this code.. its working for me.. im hopeful that your problem can be solved..
var query = $("#fltr_county").val();
var data = {"groupOp":"all","rules":[{"field":"fltr_county","op":"ew", "data": '"'+query+'"'}]};
$('#flex2').flexOptions({
filters : data,
qtype : "admin_client_contract_id",
query : query,
}).flexReload();

This works for me:
$('#useTimeRange').change(function() {
if( this.checked ) { //limit events to timestamp range
//alert("Checked " + startTime + " " + endTime);
var data = {name: 'startTime', value: $("#startTime").val()};
var data2= {name: 'endTime', value:$("#endTime").val()};
$('.flex5').flexOptions({params: [ data, data2 ]}).flexReload();
}
Here's my UI and firebug:

according to me In data you are not passing parameters as per as syntax of json
try some thing like this
var data = {name: 'fltr_county', value: $("#fltr_county").val()},{ name: 'county_ene',value:$("#county_ene").val()}
I hope this will help

Related

How to use gt/le operator in aurelia slickgrid with Odata

I want to send my own operator in odata request and not use the aurelia slickgrid inbuilt "eq" operator.
This is my column definition
{
id: 'LockoutEndDateUtc', name: 'Status', field: 'LockoutEndDateUtc', minWidth: 85, maxWidth: 95,
type: FieldType.boolean,
sortable: true,
formatter: Formatters.multiple,
params: { formatters: [this.StatusFormatter, Formatters.checkmark] },
filterable: true,
filter: {
collection: [
{ value: 'le ' + (() => {const dt = new Date(); return dt.toISOString().split('.')[0] + "Z";})(), label: 'True' },
{ value: 'gt ' + (() => {const dt = new Date(); return dt.toISOString().split('.')[0] + "Z";})(), label: 'False' }
], //['', 'True', 'False'],
model: Filters.singleSelect,//multipleSelect//singleSelect,
}
}
This is the UI
This is how the request filter looks like..
$filter=(LockoutEndDateUtc%20eq%20le%202022-06-28T12%3A59%3A25Z)
If i remove %20eq from the above request, everything else works. So my question is how to i remove %20eq. Or how do i send my own gt, le in the request.
You can't really do that on a boolean filter (you could however do it on a date filter with operator) and I don't think I've added any ways to provide a custom filter search the way you want to do it, but since you're using OData, you have a bit more control and you could change the query string yourself. To be clear, it's not at all recommended to change the OData query string, it's a last solution trick and at your own risk, but for your use case it might be the only way to achieve what you want.
prepareGrid() {
this.gridOptions = {
// ...
backendServiceApi: {
service: new GridOdataService(),
process: (query) => this.getCustomerApiCall(query),
} as OdataServiceApi
};
}
}
getCustomerApiCall(query: string) {
let finalQuery = query;
// in your case, find the boolean value from the column and modify query
// your logic to modify the query string
// untested code, but it would probably look similar
if (query.includes('LockoutEndDateUtc%20eq%20true')) {
// calculate new date and replace boolean with new date
finalQuery = query.replace('LockoutEndDateUtc%20eq%20true', 'LockoutEndDateUtc%20le%202022-06-28T12%3A59%3A25Z');
}
return finalQuery;
}
Another possible solution but requires a bit more work.
If I'd be using a regular grid, without backend service and without access to the query string, I would probably add an external drop down outside of the grid and also add the date column and then control filters in the grid by using dynamic filtering. You can see a demo at Example 23, the principle is that you keep the column's real nature (date in your case) and filter it, if you want something like a "below today's date" then add an external way of filtering dynamically (a button or a drop down) and control the filter dynamically as shown below (from Example 23)

Filter other columns based on first columns

I'm using jquery data tables and I'm assigning an array of values to the initialization of the data table. The table basically looks like this.
based on an an radio button I would like to limit the items that are display in the table and the items that are searched in the table.
For my example it would be based on the "Chart column". I want to limit the table to only show the items that are based on chart "D" or Chart "S". Here is how I'm initializing the table.
if (!$.fn.DataTable.isDataTable( '#fundLookUptbl' ) ) {
fundTable = $('#fundLookUptbl').DataTable( {
data: funds,
columns: [
{ "mData": "chart" },
{ "mData": "fund" },
{ "mData": "orgDefault" },
{ "mData": "progDefault" }
]
} );
var filteredData = fundTable
.columns( [0, 1] )
.data()
.eq( 0 )
.filter( function ( value, index ) {
return value = 'D' ? true : false;
} );
}
This is obviously not working, and the filterData variable is a lousy attempt on trying to make it work. I'm having a hard time understanding the API's. So the question is , How can initialize the table to only show the items that are based on a given chart. I know that I can remove the items of the array but i don't want to do that since I would simple like to be able to switch between chart "D" and "S" but still continue to search through the other columns.
I believe that filtering the column would solve your problem.
table.column(0).search('Bruno').draw()
So you could just filter the column when the radio button selection change
Here is a fiddle example
I´m not sure to be understanding what you want to do but here are some options:
One way is selecting by default value example "s". You can use a dropdown is easier to handled .Then select with jQuery the dafault value "s" on that dropdown and add a function
$("#DropdownId").change(function () {
var chart=$("#DropdownId").val();
});
$.ajax({
url: "url")",//url to reload page with new value
type: "POST",
data: {chart:chart},
success: function (data) {
}
});
});
on this way the filter is on backend. If you want to do something on the row depending of a column value you shoud to add something like this
"fnRowCallback": function (nRow, mData, iDisplayIndex, iDisplayIndexFull) {
if (mData["chart"] =="s") {
return nRow;
}
},
Datatables: custom function inside of fnRowCallback.
Good luck
fundTable.order( [0, 'asc'] );
Try that or look at this particular page for reference:
https://datatables.net/reference/api/order%28%29
Basically orders in pair of columnIndex in either asc(ending) or desc(ending) order.

How do I load a MultiObjectPicker with valid States for a PortfolioItem type eg PortfolioItem/FEATURE

I would like to load a MultiObjectPicker with valid States for a PortfolioItem type. I have tried with a custom query using TypeDef._refObjectName, but it does not filter the data.
var stateMultiObjectPicker = Ext.create('Rally.ui.picker.MultiObjectPicker', {
modelType: 'State',
storeConfig: {
fetch: "Name, TypeDef",
//customQuery: '(Name = "Done")', THIS WORKS
customQuery: '(TypeDef._refObjectName = "FEATURE")', // THIS DOES NOT
},
});
this.add(stateMultiObjectPicker);
Is there another way to do this? Any guidance will be appreciated!
Is there a way to use a store instead of a model in a MultiObjectPicker?
Problem solved by using:
customQuery: '(TypeDef.Name = "FEATURE")'

Rally query Projects/SubProjects

I'm trying to query for all the projects in the workspace, which I can. But when I try to query for a specific project, I get 0 results.
If I just query for projects, I get a full list. If I take one of those results and add in a:
query: 'Project.Name="Whatever"',
I get 0 results.
Full code:
//Works
var queryConfig = {
type: 'project',
key: 'projects',
fetch: 'Name'
};
rallyDataSource.findAll(queryConfig, showStories);
And then
//Doesn't work
var queryConfig = {
type: 'project',
key: 'projects',
query: 'Project.Name = "Iron Horse"',
fetch: 'Name'
};
rallyDataSource.findAll(queryConfig, showStories);
If I can figure this out, I'm also trying to get a list of all the child projects to that 1 project. I am having no success in that regard either, but I belive to even do that I'd need my first query to work.
I believe this query param will get you what you want:
query: '(Name = "Iron Horse")',

Initially selected value from store in dijit.form.FilteringSelect

I have a dojo.data.ItemFileReadStore as follows:
var partyStore = new dojo.data.ItemFileReadStore({
id: 'partyStore',
data: {
label:'name',
items:[
{value:'APPLES', name:['Apples']},
{value:'ORANGES', name:['ORANGES']},
{value:'PEARS', name:['PEARS']}
]}
});
and a dijit.form.FilteringSelect as:
var partyList = new dijit.form.FilteringSelect({
id: "partyLookup",
name: 'partyLookup',
store: partyStore,
searchAttr: "name"}, infoDiv);
How can I make the initially selected value be Oranges?
I have tried various entries for the value in the FilteringSelect so have left it out in this example.
Your data store doesn't seem right. Try changing it to:
var partyStore = new dojo.data.ItemFileReadStore({
identifier: 'value',
items:[
{value:'APPLES', name:'Apples'},
{value:'ORANGES', name:'ORANGES'},
{value:'PEARS', name:'PEARS'}
]
});
You can then set the value of the dijit.
partyList.set('value', 'ORANGES');
I had missed off the "identifier" from the store data. It seems without the identifier being set it indexes them ie. 0,1,2,3,4...
Once I set:
identifier: 'value'
the current value of the FilteringSelect comes back as the 'value' form the data.
Sorry to answer my own question, thanks to anyone who helped or took a look.