Filter is not working for columns in p-table angular? - primeng

[
($event.target.value, 'status', 'contains')
used above filter match mode with input
]1

Related

How can I filter records by their ObjectID (_id) in Ag-grid

I'm using MongoDB to store my records and am using Ag-grid react to display them. The grid has several columns including the record's ObjectID (_id), name, type, etc. Using the filter agColumnTextFilter works for the name and type fields with the columnDef of:
{
headerName: 'Column Name',
field: 'name',
filter: 'agTextColumnFilter',
},
which then leads to this query setup (using the contains filter option):
case "contains":
qp[fieldName] = new RegExp(['.*', user input string, '.*'].join(''), 'ig');
this logs the correct query:
"query db { name: /.*query string.*/gi }"
and the proper rows are displayed. Since the displayed _id is a string as well I tried something similar:
{
headerName: 'ID',
field: '_id',
valueGetter: (params) => {
let id = params.data._id;
return id.slice(id.length-5); //only display last part of ID instead of entire thing
},
filter: 'agTextColumnFilter',
},
Using the same contains logic as above the following query is logged to the console:
query db { _id: /.*_id segment.*/gi }
However, no rows are returned in this case (even though there should be rows returned). Do I need to use different logic or is there a problem with this current logic? Any advice is appreciated.
Edit: Turns out even though the ID displays as a String a cast of the string to an ObjectID is needed:
qp[fieldName] = new ObjectID(_id string)
Problem with this is searching for part of a specific ID won't work because it's not a valid ID. Searching for a full ID works but isn't ideal either. If anyone has any ideas on how I can filter just part of the ID I'd appreciate it.
You can probably set a valueFormatter on the column that displays the partial ObjectId. The filtering will be done using the full ObjectId.

anyof json schema is not working on IE React JSON Schema

We have react application, in which we have defined a JSON Schema, we have five input fields, out of which, three are required and two are optional, I want user to input atleast one out of two optional fields, hence I am using anyof keyword from JSON schema, but its not working on IE.
Below is the my code.
'type': 'object',
'appName': 'dlp',
'formName': 'CSPV',
"anyOf": [
{"required": ["address"]},
{"required": ["PHONE"]}
],
'required': [
'email'
],
Some how its not working on IE, any alternative solution for this, any help would be appreciated. I am using React JSON Schema.

how to add custom filters to ng-table-dynamic?

I have an Angular 1.6 app that uses ngTable (ng-table-dynamic). It works well, but I cannot figure out a way to add basic filters to the rows. I'm moving from ng-table to ng-table-dynamic
From:
%table{ng-table: "$ctrl.tableParams"}
%tr{ng-repeat: "unit in $data track by unit.id"}
%td{data-title: "'name'", sortable: "'name'"}
{{unit.name}}
%td{data-title: "'cost'", sortable: "'cost'"}
{{unit.cost | currency:"$":0}}
to:
%table{ng-table-dynamic: "$ctrl.tableParams with $ctrl.columns"}
%tr{ng-repeat: "unit in $data track by unit.id"}
%td{ng-repeat: "col in $columns"}
{{unit[col.field]}}
Any ideas on how to get that currency filter to apply for ng-table-dynamic?

Customise select columns in ui-grid

Is it possible to put a custom column definition for select fields in a ui grid and pick up the rest of the fields from the data schema? This use case arises because my json data schema is variable and there's just one column I'm sure about(its presence in data) and would like to apply a custom cell template to just that column.
Grid options:
$scope.gridOptions = {
data: data,
columnDefs: [
{ field: 'name', width: 250, cellTemplate: "../../tpl/grid/name_template.html" }
]
}
where data is the json object of variable schema.
If I define the grid this way, only the name field from my data object will be displayed in the grid. Is it possible to use the custom column def for the name field and also display the other objects in the data object without specifying column definitions for them?
To provide more clarity:
my data object can be:
[{name: 'apple', type: 'fruit', seasonal: true}]
or:
[{name: 'apple', color: 'green', taste: 'sour'}]
Basically my use case is such that there's no way for me to know before hand what columns will be returned from the query that initialises the grid data object but I'm sure of the fact that a name column will be part of the data returned by the query. I would want to supply a custom cell template and other properties to the name field and also display the other columns that might be there.
The normal behaviour is that if I specify a column definition for one column in the field, then I have to specify definitions for all the other columns that are part of the data to make them visible and in my case I don't know what the other field names might be.
$scope.gridOptions = {
data: data,
columnDefs: [
{ field: 'name', width: 250, cellTemplate: $.get('url-to-your-template.html') }
]
}
Check if the above works. You can use your own service for fetching template

ExtJS 5 - Order Grid Columns irrelevant of it array positioning

Can someone help me to figure out a way to arrange the columns irrelevant of it columns array positioning? For example, in below grid columns array i just want to display Phone as 1st column and Name as 2nd column. How can i achieve that programmatically?
Columns Array:-
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Email',
dataIndex: 'email'
}, {
text: 'Phone',
dataIndex: 'phone'
}]
While debugging the grid column config with Chrome developer tools, i figured out a parameter "fullColumnIndex" which value getting increased for every column. But specifying that explicitly doesn't make any difference :(
Thanks!
You can do it by using reconfigure method. Docs — http://docs.sencha.com/extjs/5.1/5.1.0-apidocs/#!/api/Ext.panel.Table-method-reconfigure
Here is the description of this method:
reconfigure( [store], [columns] )
Reconfigures the grid / tree with a new store/columns. Either the store or the > columns can be omitted if you don't wish to change them.
The enableLocking config should be set to true before the reconfigure method is > executed if locked columns are intended to be used.
Parameters
store : Ext.data.Store (optional)
The new store. You can pass null if no new store.
columns : Object[] (optional)
An array of column configs

Resources