Search is not working with filter toolbar in JQGrid - search

I am facing issue while loaidng the data in JQGrid at a later stage in place of at the time of ceating grid. I am using filter toolbar for search.
following is the code I am using:
Creating Grid
jQuery("#list").jqGrid({
datatype: 'local',
colNames: [my col names],
colModel: [my col model],
jsonReader: {
root: "rows",
page: "page",
total: "total",
//records: "records",
repeatitems: false
},
height: 300,
viewrecords: true,
gridComplete: this.onGridComplete,
ondblClickRow: this.rowDblClick,
onSelectRow: this.selectRow,
headertitles: false,
loadtext: "Loading...",
sortable: true,
altRows: true,
loadonce: true,
rowNum: 100,
pager: '#pager',
root: "rows",
rowList: [100, 200, 300],
pagination: true,
ignoreCase: true
})
Load data at later stage
if(gridDataStr != "none") // gridDatStr has data
{
grid.initialize(); // create the grid
var myjsongrid = JSON.parse(gridDataStr);
grid.table[0].addJSONData(myjsongrid);
grid.table.jqGrid('setGridParam',{datatype:'json', data:myjsongrid}).trigger('reloadGrid');
if (myjsongrid["rows"].length > 1)
{
grid.table.filterToolbar({
stringResult: true,
searchOnEnter: false
});
}
}
However if I load the same data at the time of creating the grid with datatype:json and using some valid url, searching is working well.
Any suggestions?

The method addJSONData can not be used to work with the jqGrid having the 'local' datatype.
You can use addRowData and to use localReader instead of jsonReader or set data parameter of jqGrid with respect of setGridParam method and then call jQuery("#list")[0].refreshIndex() (see here) and reload the grid.

Related

MongoDB query that contain at least one of filters specified in an object

I have a collection in MongoDB that is structured like this:
"5d33488672886334cd21904xx": {
"ownerId": "5d333551k99951924fb3208",
"createdAt": 1582456098,
....phone
....email
....etc
"mainActivities": {
"dogWalking": true
},
"secActivities": {
"washing": true,
"houseSitting": true,
"dogSitting": true,
"training": true,
"trainingEquipment": true,
"selectionAdvice": true,
"institutionsBusinesses": true
}
}
"5d33488672886334cd21904xx": {
"ownerId": "5d333d344d46ed924fb3208",
"createdAt": 99999995,
....phone
....email
....etc
"mainActivities": {
"dogWalking": true
},
"secActivities": {
"washing": false,
"houseSitting": false,
"dogSitting": false,
"training": true,
"trainingEquipment": false,
"selectionAdvice": true,
"institutionsBusinesses": true
}
}
i am sending filters from the front end like so :
{
"filters": {
"mainActivities": {
"dogWalking": true
},
"secActivities": {
"washing": false,
"houseSitting": true,
"dogSitting": true,
"training": true,
"trainingEquipment": true,
"selectionAdvice": false,
"institutionsBusinesses": true
}
}
}
i want to get all the documents that answer the filters and not EXACT match .
Example:
if i am a dog walker service named "Xdog" , who give all the 6/6 activities (secActivities)
in the front end , when user select 2/6 filters i miss this "Xdog" service.
i get to a function who return only the document that specify EXACT match and its not good because
i am missing the services who actually answer this 2/6 filters..
right now i am sending and spreading the "filterBy" variable into the find() function .
Any suggestion would be great i am weak in Databases commands.
Sorry for my poor English!
The way to do partial match is with $or, but I don't think that will do what you actually want.
The example query you showed above is looking for dog walking services that do not provide washing or selectionAdvice services. Your description suggests that you do not want to consider these 2 services because the user did not specify them. In that case, leave these 2 out of the query entirely, using the user selections to add only the relevant fields, like:
.find({
"mainActivities": {
"dogWalking": true
},
"secActivities": {
"houseSitting": true,
"dogSitting": true,
"training": true,
"trainingEquipment": true,
"institutionsBusinesses": true
}
}
If the filters object is already built, you would need to remove the properties that are false. See How do I remove a property from a JavaScript object?

Remove checkbox-menu Ag-Grid - VueJs - NodeJs

I need to remove this checkbox from my menu, can anyone help me?
I am using "VueJS".
My current code:
{
headerName: "",
width: 30,
checkboxSelection: true,
suppressMenu: true,
filter: false,
floatingFilterComponentParams: { suppressFilterButton: true }
},
https://prnt.sc/q8d4ci

How to sum the values of a JQgrid footer row when the value is already in linked

I have this code that needs to be display the total sum of few columns, The JQgrid works fine in normal column value. But when that column value is linked, It shows Nan
grid.jqGrid({
data: mydata,
datatype: "local",
height: containerHeight,
width: containerWidth,
colNames:[
//'Region/Purchaser Name',
'Order No. / Invoice No.','PO No.','Ship To','Ship To Attention','Address','City','State / Zip','Requested Ship Date','Shipped Date','Total Qty Ordered','Shipped to WF','Open Qty'],
colModel:[
//{name:'REGION',index:'REGION', width:20},
{name:'DUMMYMACNO',index:'MACNO', width:19, align:"center"},
{name:'PONUM',index:'PONUM', width:17},
{name:'SHIPTO',index:'SHIPTO', width:17},
{name:'ATTN',index:'ATTN', width:19,align:"center",formatter:nullFormatter},
{name:'ADDRESS',index:'ADDRESS', width:19},
{name:'CITYJ1',index:'CITYJ1', width:10},
{name:'STZIP',index:'STZIP', width:10},
{name:'SDATE',index:'SDATE', width:10},
{name:'INVDATE',index:'INVDATE', width:10},
{name:'TQO',index:'TQO', width:4, align:"center"},
{name:'DQTY',index:'DQTY', width:5, search:false, align:"center", sorttype:"float", formatter:function(cellvalue, options, rowObject){return ''+cellvalue+'';},classes: 'blue-text'},
{name:'OQO',index:'OQO', width:6, search:false, align:"center", sorttype:"float", formatter:function(cellvalue, options, rowObject){return ''+cellvalue+'';}},
],
rowNum:100,
rowList : [100,150,200],
loadonce:true,
mtype: "GET",
casesensitive: true,
rownumbers: true,
rownumWidth: 40,
ignoreCase: true,
gridview: true,
pager: '#locationlistpagination',
sortname: 'SONO',
viewrecords: true,
loadComplete: function() {
$("tr.jqgrow:odd").addClass('jqgrow-alt-row');
},
sortorder: "asc",
footerrow: true,
gridComplete: function() {
var colsum = 0;
var colsum1 = 0;
var colSum2 = 'Total';
var colSum4 = 'Total';
var colSum = grid.jqGrid('getCol', 'DQTY', true, 'sum');
var colSum4 = grid.jqGrid('getCol', 'OQO', true, 'sum');
var colSum1 = grid.jqGrid('getCol', 'TQO', false, 'sum');
grid.jqGrid('footerData', 'set', { OQO: colSum });
grid.jqGrid('footerData', 'set', { DQTY: colSum4 });
grid.jqGrid('footerData', 'set', { TQO: colSum1 });
grid.jqGrid('footerData', 'set', { SDATE : colSum2 });;
}
})
The query works fine in ColSum1 and colSum2, but its shows Nan in ColSum and Colsum4. Can any one have a way to solve this
The getCol method sum a values which are numbers in grid, after they are formatted from the formatter. The values where you get NaN are not numbers, but links after formatting. In order this to work correctly you should define a unformat function which will convert back the link to a number. See the Guriddo docs here

How to delete a column in dojox/grid/EnhancedGrid

Do we have any way to delete a column in dojox/grid/EnhancedGrid. Please let us know if there is any solution for this.
Please find my sample grid.
Details: it creates a dojox/grid/EnhancedGrid and has an action associated with clicking a header row. What action can I add to delete the column?
var dataStore = new ObjectStore({objectStore: objectStoreMemory});
// grid
grid = new EnhancedGrid({
selectable: true,
store: dataStore,
structure : [ {
name : "Country",
field : "Country",
width : "150px",
reorderable: false,
editable : true
}, {
name : "Abbreviation",
field : "Abbreviation",
width : "120px",
reorderable: false,
editable : true
}, {
name : "Capital",
field : "Capital",
width : "100%",
reorderable: false,
editable : true
} ],
rowSelector: '20px',
plugins: {
pagination: {
pageSizes: ["10", "25", "50", "100"],
description: true,
sizeSwitch: true,
pageStepper: true,
gotoButton: true,
maxPageStep: 5,
position: "bottom"
}
},
dodblclick: function() {
alert("Header clicked");
}
}, "grid");
grid.startup();
you need to use the method
grid.setStructure(newLayout);
or
grid.set('structure',newLayout);
here newLayout is the layout that you need to create without the columns that you need.
Hope this helps.

Alter SVG After Highcharts is Redrawn

I'm trying to specifically target the first and last x-axis labels, which are text elements, and alter their attributes.
To preface this issue, I was trying to keep the first and last x-axis labels within the confines of the Highcharts container. Unfortunately, they are cutting off in the UI.
This is my configuration:
xAxis: [{
type: 'datetime',
showFirstLabel: true,
showLastLabel: true,
labels: {
step: 3,
formatter: function(){
return options.labels[this.value];
},
style: {
fontSize: '10px',
color: '#9c9c9c'
},
// x: 5,
y: 10
},
startOnTick: true,
// lineColor: 'transparent',
tickLength: 0,
minPadding: 0,
maxPadding: 0
}],
The step key is causing this I realize. Otherwise, I would be able to use overflow:justify, but I wanted the step. So, I then decided that perhaps altering the SVG would be a good solution. It worked when the chart is first loaded, but it does not work when being redrawn.
This was my solution on 'load', which I'd like to replicate on 'redraw':
Highcharts.Chart.prototype.callbacks.push(function(chart){
$('.highcharts-axis-labels.highcharts-xaxis-labels text').first().attr('x', 25);
$('.highcharts-axis-labels.highcharts-xaxis-labels text').last().attr('x', 813);
});
You should configure these callbacks in the options of your chart. It's cleaner that way:
function moveLabels(){
$('.highcharts-axis-labels.highcharts-xaxis-labels text').first().attr('x', 25);
$('.highcharts-axis-labels.highcharts-xaxis-labels text').last().attr('x', 813);
}
$('#container').highcharts({
chart: {
events: {
load: moveLabels
redraw: moveLabels
}
}
},
...

Resources