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 am using Datatable plugin. I am fetching data from server side. Now I want to assign unique id to each row. How do I do that?
It would be better if I can assign id from client side(by setting any option or property of datatable I guess).
Thanks.
You can do like
$('#myTable').DataTable( {
ajax: '/api/staff',
rowId: 'staffId'
} );
Here staffId is property from your data source.
Please check Document
I set up a datatables that initially gets from server some data and represents it, but then everything is left to the client. Some options are:
serverSide: false,
sAjaxSource: mySource,
My $.fn.DataTable.version is 1.10.2.
Then I need to change, client-side, the aaData under the table because some working on data is performed. I need to update the DT to show the client-altered temporary data without send another request to server (for two reason: prevent useless traffic and because that data is being altered).
I am looking for a way to edit the underlying DT databean to edit it, so then calling again
myTable.draw();
on my table I obtain a refresh realtime without sending another get to the server.
The question is, can I access DT data array, and can I edit it?
How is it done if is possible?
EDIT: I need to feed the table the full bean array as it initially took from the server, same format. So individual row/cell add/edit and client-side building functions are not suitable in my case, unless I manually cicle all objects.
SOLUTION
Use the code below:
// Retrieve data
var data = table.ajax.json();
// Modify data
$.each(data.data, function(){
this[0] = 'John Smith';
});
// Clear table
table.clear();
// Add updated data
table.rows.add(data.data);
// Redraw table
table.draw();
DEMO
See this jsFiddle for code and demonstration.
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();
I have a grid with local memory store. I can list the records in pages using pagingtoolbar. However, after filtering the data, I load filtered records to a new store and bind this store to the same pagingtoolbar. Then pagingtoolbar becomes disabled. In this state, when I check the pagingtoolbar's data it shows the correct values (total records and pages etc.). But the toolbar is disabled.
How can I update the view of paging toolbar?
Here some code:
var newStore = Ext.create('APP.myLocalStore', {
data: filteredStore.data,
totalCount: filteredStore.count()
});
pagingToolbar.bindStore();
pagingToolbar.bindStore(newStore);
pagingToolbar.moveFirst();
I am using extjs 4.x
You can use pagination bar refresh also. Try
Ext.getCmp('pagination bar').doRefresh()