I started using Slickgrid recently but have not gotten in depth with it. I'm trying to connect it to my own MySQL database but I haven't gotten any luck doing so.
I want this for displaying purposes so all I need (for now) is to show up the data in the database into the Slickgrid.
Other than the connection to the database
var getDB = new ActiveXObject("ADODB.Connection") ;
var cntstring = "DSN=adsn;UID=root;PWD=1234";
getDB.Open(cntstring);
var rset = new ActiveXObject("ADODB.Recordset");
I don't know how to populate the rest to each cell in the Slickgrid.
Any help is greatly appreciated!
Build a grid with sample data first. Get it working the way you want first. Then retrieve data from the DB and format it like the sample data.
Related
I am new to PrimeFaces. I would like to seek the example or tutorial that can guide on how to make a simple live pie chart when new data inserted into database.
For example, when a data inserted into database, the pie chart would get the value from database and it would reflected on pie chart.
I got the sample from this prime faces website but that sample is without database value.
PrimeFaces simple live chart
I am using PrimeFaces, jsf2.2, spring-hibernate & mysql for my small project.
Anyone can help where can I get any sample or tutorial can refer?
Thanks in advanceSnip the sample chart from primefaces.org
This is really vague, but you can write a method to get value (example sum or count from db) . then in the bean like the example only the first two values would change.
public PieChartModel getLivePieModel() {
int random1 = abstractFacade.countCandidate(candidate1); // Method to get data from db
int random2 = abstractFacade.countCandidate(candidate2); // Method to get data from db
livePieModel.getData().put("Candidate 1", random1);
livePieModel.getData().put("Candidate 2", random2);
livePieModel.setTitle("Votes");
livePieModel.setLegendPosition("ne");
return livePieModel;
}
The xhtml will stay the same as the demo
My question is quite similar to this one.
I get the same data (attributes of objects, each row represents an object) from the database for two of my pages, one page to edit the data and one page to view it. To reduce redundant code and to improve maintaining I wanted to write the piece of code that loads the data only once.
My idea was to use a _PageStart.cshtml. But with that I only can store strings in the PageData array but not Objects.
So what is the best way to make the rows from the database available on several pages?
Here is how I get the data from the database:
var db = Database.Open("mydb");
String query = "select * from motors";
var rows = db.Query(query);
System.Data.DataTable motors = new System.Data.DataTable();
motors.Columns.Add("posX", typeof(int));
motors.Columns.Add("posY", typeof(int));
IEnumerator<dynamic> en = rows.GetEnumerator();
while (en.MoveNext()) {
motors.Rows.Add(en.Current.posX, en.Current.posY);
}
I would like to access the DataTable motors on different pages.
All you have to do is create a page that only has your code in it, Then on whatever page you want it displayed just use:
#RenderPage("~/yourpage.cshtml");
Goal: to update a Fusion Table by replacing old rows by new ones from a csv file without headers using ReplaceRows().
I am using the Google.Apis.Fusiontables.v2 library.
I have read and reread the documentation, but still can`t get my code working.
Authentication is working and I am able to perform simple INSERTs without issue:
string sql = "INSERT INTO 11t9VLt3vzb46oGQMaS2LTSPWUyBYNcfi1shkmvag (rpu_id, NO_BAIL, 'Usage (description)', 'Use (description)', 'Sup. louable m2', 'Sup. Utilisable m2', 'SumTotal Lou', 'Percent Lou', 'SumTotal Util', 'Percent Util') VALUES (9999,1111,'Test','Test En',1,2,3,4,5,6)"
Sqlresponse sqlRspnse = service.Query.Sql(sql).Execute();
I have tried ReplaceRowsMediaUpload and ReplaceRowsMediaUpload directly from the TableResource class without luck.
Calling the upload function from the service object doesn't error out, but I'm not sure what to do next that would actually replace the rows in the Fusion Table (service is a FusiontablesService):
StreamReader str = new StreamReader(Server.MapPath("~") + #"\sample2.csv");
service.Table.ReplaceRows("1X7JMLFy75uq20UnU6cLrGTTDfp6lLuD1Fc3vYYjQ", str.BaseStream, "text/csv").Upload();
I've tried:
service.Table.ReplaceRows("1X7JMLFy75uq20UnU6cLrGTTDfp6lLuD1Fc3vYYjQ").Execute()
following the upload, but this just puts the Fusion table in "stuck" mode.
Can someone please provide the lines required to make ReplaceRows work? (Explanations would be appreciated, but aren't necessary!).
You should change "text/csv" for "application/octet-stream". (See accepted MIME type here: https://developers.google.com/fusiontables/docs/v2/reference/table/replaceRows)
StreamReader str = new StreamReader(Server.MapPath("~") + #"\sample2.csv");
service.Table.ReplaceRows("1X7JMLFy75uq20UnU6cLrGTTDfp6lLuD1Fc3vYYjQ", str.BaseStream, "application/octet-stream").Upload();
The call to Upload should be enough.
Also, try to create a new table to test it out, to be sure it is setup correctly.
You can use a REST API call to replace a row in your Google Fusion table directly instead of writing methods to do that. Here is an example:
POST https://www.googleapis.com/upload/fusiontables/v2/tables/tableId/replace
Please refer to this document for more details, it has a testing environment tool too.
What are the requirements for formatting a 'store' used by a dijit.form.Select?
Currently i'm pulling a json style db (backend is a mongoStore) and using THE SAME DB in a dojox.data.DataGrid and a dijit.form.Select. I set the db as the 'store' attribute for both, and for the datagrid it works perfectly (after specificying the layout).
This works....
this.setGrid = new dojox.grid.DataGrid({
store: this.db,
structure: this.setGridLayout
});
In the Select however it does not work at all. In the drop down i get thin blank spaces roughly equivalent in number to the number of objects in the db. What do i need to specify in the select/how do i need to format the data so that the select can display the data correctly?
This doesnt work...
var select = new dijit.form.Select({
id:dbName+"Select",
store: this.db
});
I don't know mongoStore and I've tried only with a dojo.data.ItemFileReadStore, so I don't know if what I write is useful for you.
I think that the Select's options are created using store.getLabel() and store.getIdentity(), see the function _getOptionObjForItem of dijit.form._FormSelectWidget.
I have a requirement that,
I populate all database in one DropDownList and when i changed the database name.
I need to display all objects present in the database into a gridview.
I need to do it in LINQ to SQl
could any one please help me to solve this problem?
Thanks and Regards,
G. Kiran
I found this code somewhere
Northwind db = ...from somewhere
var model = db.Mapping;
foreach (var mt in model.GetTables())
Console.WriteLine(mt.TableName);