I have a table that receives a .JSON.
I have created some filters and I would like to save them but without saving the information that I received at that time with the filter.
I already tried:
pivot.getData({},
function(data) {
console.log(data);
},
function(data) {
console.log(data);
}
);
Too
var report = pivot.getReport();
console.log(report);
by last
pivot.save({filename:'reporte.json',embedData : false });
Thanks for your help
There are several ways to achieve what you need:
You can still use:
var report = pivot.getReport();
the data information is stored in report["dataSource"]. In such a
case, you can easily remove the unnecessary object the following
way:
delete report["dataSource"];
After that, the JSON config is saved as a file to the disk using
the following approach:
JavaScript: Create and save file.
The disadvantage of such a solution is that you cannot use the saved
JSON config to restore the view since it lacks the data part. You will need to add the "dataSource" part when you decide to restore
the view. Therefore, the solution that described below looks better
for me.
You can create a web service that returns the data file or simply put the JSON data file to the server. In such a case,
WebDataRocks will load the data for you. Then, when you decide to
save the config, only the link to the data will be saved to config.
Here is the reference to docs:
https://www.webdatarocks.com/doc/data-source-object/. The
"filename" property represents the link which leads to your data
file.
In such a case you don't need any additional customization for the
"Save" functionality. You can use a default one. Then it is easy to restore the view using the saved config.
I am trying to build an app for users to submit their work times in but am having trouble with pulling additional data into the grid.
Eg: If a user were to type in there employee code of 0000 into the Employee Code Column the Employee Name Field would need to update to read "John Doe" All this data is stored in databases on the back end and I have been able to access it on refresh eg. If the page is reloaded after the new row has been created and the data is present it will pull the correct data in, but i do not want them to have to refresh the page to do this. How can I pull in the extra data after the cell has been updated.
The Grid is created on the page with JavaScript as follows:
timesheetGrid.setColumnIds("Column Names, Column Names");
timesheetGrid.setImagePath("codebase/imgs/"); //set the image path for the grids icons
timesheetGrid.setInitWidths("70,100,100,100,70,100,150,100,70,70,100,70,70,*,*"); //sets the initial widths of columns
timesheetGrid.setColAlign("center,center,center,center,center,center,center,center,center,center,center,center,center,left,left"); //sets the alignment of columns
timesheetGrid.setColTypes("edn,ro,dhxCalendar,ro,edn,ro,ed,ro,ro,ro,ed,edn,ch,txt,ro"); //sets the types of columns
timesheetGrid.setColSorting("str,str,date,date,str,str,str,str,str,str,str,str,str,str,str"); //sets the sorting types of columns
timesheetGrid.setDateFormat("%Y-%m-%d"); //Set the Date Format to be used in the Grid
timesheetGrid.attachHeader("#text_filter,#text_filter,#text_filter,,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,,,");
timesheetGrid.setColumnHidden(3,true);
timesheetGrid.enableEditEvents(true,false,true);
timesheetGrid.init();
//timesheetGrid.makeFilter("WeekEnding",0); //TODO: Add Filter For Week Ending
//this.lockRow(id, true); //Make Specific Row Read Only TODO: Non Active Week Rows Read Only
timesheetGrid.load("data/timesheets.php");
var dpg = new dataProcessor("data/timesheets.php");
dpg.enableDataNames(true); // will use names instead of indexes
dpg.init(timesheetGrid);
PHP is used to pull data from the correct avenues
require("../codebase/connector/grid_connector.php");//adds the connector engine
$conn = new GridConnector($res,"MySQL"); //initializes the connector object
if ($conn->is_select_mode()) {//code for loading data
SQL Code is HERE
}else { //code for other operations - i.e. update/insert/delete
OTHER SQL CODE IS HERE
}
As the Data is sensitive I cannot display any of it sorry for any inconvenience.
Any Help would be much appreciated.
If the data you're providing is XML you can attach an event to your grid and call this grid.updateFromXML("data/timesheets.php");
This will parse and paint the whole grid information
If you're looking to update just the row you updated you can send via GET the id of the row and it will only parse and paint the row you're sending
grid.updateFromXML("data/timesheets.php?for=" + row_id));
Full Code would be something like this:
dpg.defineAction ("update", myUpdate);
function myUpdate(tag){
timesheetGrid.updateFromXML("data/timesheets.php?for="+tag.getAttribute("sid"));
return true;
}
If the data you're retrieving is not XML formatted, I'm afraid you would need to update the values from the row manually via the same event.
I have a grid with data in Lighswitch application. Grid has on every column posibility to filter column. Thanks to lsEnhancedTable
Right now I am sending an ajax request to the web api controler with the list of ids of the Customers that I want to export. It works but with a lot of data it is very slow because I have to turn off the paging of the data to get all visible customers ids so I can iterate over the VisualCollection.
To optimize this I would have to turn on back the paging of the data to 50 records so that the initial load is fast and move the loading of the data to a save/export to excel button.
Possible solutions:
Load data all data on save button click. To do this I have to somehow load all items before I can iterate over collection.
The code bellow locks UI thread since the loadMore is async. How to load all data synchronously? Ideally I would like to have some kind of progress view using a msls.showProgress.
while(3<4)
{
if (screen.tblCustomers.canLoadMore) {
screen.tblCustomers.loadMore();
}
else
break;
}
var visibleItemsIds = msls.iterate(screen.tblCustomers.data)
.where(function (c) {
return c;
})
Second approach would be turn on paging and pass just the filters applied by the users to the web api controller so I can query database and return only filtered records. But I don't know how to do that.
Third approach is the one that I am using right now. Turn off the paging->iterate over visual collection, get the customers id, pass them to the controller and return a filtered excel. This doesn't work well when there are a lot of records.
Iterate over filtered collection in the server side? I don't know if there is a way to do this in Lighswitch?
Here's an option for client side javascript.
// First build the OData filter string.
var filter = "(FieldName eq " + msls._toODataString("value", ":String") + ")";
// Then query the database.
myapp.activeDataWorkspace.ApplicationData.[TableName].filter(filter).execute().then(function (result) { ... });
I have multiple grids on a single page so my PHP needs to know which jqGrid POST data came from. I thought I could easily use something such as:
jQuery('#grid1').jqGrid({
...
postData:
{
grid: function() { return $(this).attr('id'); }
},
...
});
POST certainly contains grid but the value is populated. For testing I put...
alert($(this).attr('id'));
...elsewhere in my code and it displayed the grid name. I'm not sure how/where to get the value into POST though.
Your help is appreciated, thank you.
I simply added a new field to the POST which contains the "type" of data being submitted so my API knows what it is being handed.
So I have a rather unique situation. I am using JQuery to gather some data based on two date ranges, what is returned as a response in the $data variable (I am using Ajax) I have set, is a html table.
Now I don't want the user to ever see this table, I want to use This jquery plugin to download the CSV file of that table. The question is, if the table sits inside of a $data and can be seen via the network tab in Chrom Dev Tools, under Response, is it possible to be manipulated with Jquery?
In our inhouse framework, we do the following to get Ajax Data:
// The following belongs to a JS class method.
data = {
startDate : $('.startDate').val(),
endDate : $('.endDate').val()
}
CT.postSynch('report/payRollReport/downloadPayRoleReport', {data : data}, function(data){
console.log(data);
});
We pass a data object to our Ajax wrapper, call a controller with an action (in this case downloadPayRoleReport translates to ajaxDownloadPayRoleReport()) which in turn returns an HTML table, which I can view via console.log(data)
I want to use the above linked plugin on data to then turn this html table into a csv and instant download.
Question is, can this be done?
You can create a jQuery object from the table. Then you can do anything to the jQuery object just like you could if it were actually on the DOM. You can always put the table on the DOM as well off screen, but I think any chance you have to not touch the DOM you should take it.
var myTable = $(data);
myTable.mySpecialTableMethodToExportToCSV();