Sigma Php Ajax framework, Ajax Components, GUI Builder
February 09, 2012, 11:19:59 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
Sigma Php Ajax framework, Ajax Components, GUI Builder
>
Sigma Grid
>
Sigma Grid - Q&A
(Moderators:
steven
,
gbolanoscruz
) >
Calculated columns
Pages: [
1
]
« previous
next »
Print
Author
Topic: Calculated columns (Read 2049 times)
anikitos
Jr. Member
Posts: 11
Calculated columns
«
on:
August 07, 2008, 01:19:23 PM »
Is it possible to have calculated columns in such way where user would edit one column and another would be affected in a predefined way?
Example: Distance, Speed, Time columns, where changing one would affect the other two. I understand that this can all be done by saving data and sending a request to server, but can it be done on the fly in client side? If so how?
Also, after the cell has been edited, is it possible to change the color until the save action?
And, is it possible to modify multiple cells at the same time in one column, or row? For example a user would highlight multiple cells, and edit with same value.
«
Last Edit: August 07, 2008, 01:57:59 PM by anikitos
»
Logged
steven
Moderator
Hero Member
Posts: 546
Re: Calculated columns
«
Reply #1 on:
August 08, 2008, 01:51:38 AM »
Calculated columns is supported and you can see a sample at
http://www.sigmawidgets.com/products/sigma_grid2/demos/example_formular.html
.
After the cell has been modified, there will be a red marker at the top corner.
For row & column bulk editing, I think you need to do some scripts for that. The following post may give you some idea about that.
«
Last Edit: August 08, 2008, 02:22:49 AM by steven
»
Logged
Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
steven
Moderator
Hero Member
Posts: 546
Re: Calculated columns
«
Reply #2 on:
August 08, 2008, 02:21:23 AM »
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" --> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> <title>Sigma Ajax grid demo - Dynamic search</title> <meta http-equiv="Content-Language" content="en-us" /> <meta name="keywords" content="dhtml grid, AJAX grid, filter, dynamic search" > <meta name="description" content="How to apply rows filter and implement dynamic search" > <script src="highlight/jssc3.js" type="text/javascript"></script> <link href="highlight/style.css" rel="stylesheet" type="text/css" /> <style type="text/css" media="all">@import "./css/doc_no_left.css";</style> <script src="../../../js/menu.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" media="all" href="../grid/calendar/calendar-blue.css" /> <script type="text/javascript" src="../grid/calendar/calendar.js"></script> <script type="text/javascript" src="../grid/calendar/calendar-cn-utf8.js"></script> <script type="text/javascript" src="../grid/calendar/calendar-setup.js"></script> <link rel="stylesheet" type="text/css" href="../grid/gt_grid.css" /> <link rel="stylesheet" type="text/css" href="../grid/skin/vista/skinstyle.css" /> <script type="text/javascript" src="./data/test_data.js"></script> <script type="text/javascript" src="../grid/gt_msg_en.js"></script> <script type="text/javascript" src="../grid/gt_const.js"></script> <script type="text/javascript" src="../grid/gt_grid_all.js"></script> <script type="text/javascript" src="../grid/flashchart/fusioncharts/FusionCharts.js"></script> <script type="text/javascript" > var grid_demo_id = "myGrid1" ; var dsOption= { fields :[ {name : 'no' }, {name : 'country' }, {name : 'customer' }, {name : 'employee' }, {name : 'bill2005' ,type: 'float' }, {name : 'bill2006' ,type: 'float' }, {name : 'bill2007' ,type: 'float' }, {name : 'bill2008' ,type: 'float' }, {name : 'orderDate' ,type:'date' } ], recordType : 'array' } var colsOption = [ {id: 'no' , header: "Order No" , width :60 }, {id: 'employee' , header: "Employee" , width :80 }, {id: 'country' , header: "Country" , width :70 }, {id: 'customer' , header: "Customer" , width :80 }, {id: 'bill2005' , header: "2005" , width :60}, {id: 'bill2006' , header: "2006" , width :60}, {id: 'bill2007' , header: "2007" , width :60}, {id: 'bill2008' , header: "2008" , width :60}, {id: 'orderDate' , header: "Delivery Date" , width :100} ]; function getTestData(grid) { var responseT={}; var pageInfo= grid.getPageInfo(); responseT[grid.CONST.data]=__TEST_DATA__.slice( pageInfo.startRowNum-1,pageInfo.endRowNum); responseT[grid.CONST.pageInfo]={totalRowNum :__TEST_DATA__.length } ; return responseT; } var g_record = null; var gridOption={ debug : false, id : grid_demo_id, loadUrl : getTestData, saveUrl : './data/masterData.js', width: "700", //"100%", // 700, height: "200", //"100%", // 330, container : 'gridbox', replaceContainer : true, listenResize : false, //showIndexColumn : true, resizable : false, editable : false, remoteSort : false, allow_gmenu : false, allow_freeze : false, groupable : false, toolbarPosition : 'bottom', encoding : 'UTF-8', // Sigma.$encoding(), pageStateBar : null , //'outStateBar', dataset : dsOption , columns : colsOption , clickStartEdit : false , defaultRecord : ["","","","",0,0,0,0,"2008-01-01"], pageInfo : { pageSize:60 }, beforeSelectRow:function(value, record , cell, row, colNO, rowNO, columnObj,grid){ g_record = record; return true; } }; var mygrid=new Sigma.Grid( gridOption ); Sigma.Util.onLoad( Sigma.Grid.render(mygrid) ); ////////////////////////////////////////////////////////// </script> </head> <body> Select a row and type something here:<input type="text" id="f_value1" value="" onKeyUp="doFilter()"> <div id="bigbox" style="margin:15px;display:!none;"> <div id="gridbox" style="border:0px solid #cccccc;background-color:#f3f3f3;padding:5px;height:200px;width:700px;" ></div> </div> <script type="text/javascript" > function doFilter() { if(g_record == null) return; for(var i=0; i<g_record.length;i++){ g_record[i] = document.getElementById("f_value1").value; } var grid=Sigma.$grid("myGrid1"); grid.refresh(); } </script> </body> </html>
Logged
Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
anikitos
Jr. Member
Posts: 11
Re: Calculated columns
«
Reply #3 on:
August 08, 2008, 09:45:04 AM »
Thank you for your reply, Steven.
I am looking through the example that you provided on the formulaic columns, and I am not understanding something, the script : {id: 'bill_avg' , header: "Bill Avg",width :60, initValue : example_initAvg}, has a method example_initAvg which is defined to take as I understand following parameters : a grid object (grid), row number (rn), and record, but the implementation does not use any of them, plus record is not used in the defenition.
I am confused about how to get the row number while defining colsOption, I see the getRowNumber in the gt_grid_all.js, but not sure how to use it. Also, how do I pass the grid object? Would it be mygrid defined as var mygrid=new Sigma.Grid( gridOption ); ?
Logged
steven
Moderator
Hero Member
Posts: 546
Re: Calculated columns
«
Reply #4 on:
August 10, 2008, 11:14:41 PM »
Do understand the following code?
function example_initAvg(grid,rn,record){ var bill2005 = grid.getColumnValue('bill2005',rn); var bill2006 = grid.getColumnValue('bill2006',rn); var bill2007 = grid.getColumnValue('bill2007',rn); var bill2008 = grid.getColumnValue('bill2008',rn); var avg =(bill2005+bill2006+bill2007+bill2008)/4; avg = parseInt(avg*100)/100; return avg; }
Logged
Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
anikitos
Jr. Member
Posts: 11
Re: Calculated columns
«
Reply #5 on:
August 11, 2008, 07:41:15 AM »
Yes, I do understand the method. But I am lost on this:
{id: 'bill_avg' , header: "Bill Avg",width :60, initValue : example_initAvg}, this is called in the definition of colsOption
example_initAvg is called without any parameters passed. I understand that this might be a mistatype, and it should be {id: 'bill_avg' , header: "Bill Avg",width :60, initValue : example_initAvg(grid, rn, record)}, if that is the case, how do i get the value of "rn", and "grid". Also why is there "record" in the parameter list, but not being used?
I am just trying to figure out if there is a mistype , or if I am misunderstanding something.
Thank you.
Logged
steven
Moderator
Hero Member
Posts: 546
Re: Calculated columns
«
Reply #6 on:
August 12, 2008, 07:36:52 PM »
You need not do that like this way.
{id: 'bill_avg' , header: "Bill Avg",width :60, initValue : example_initAvg(grid, rn, record)}
If you look into JavaScript, you will notice that initValue is a callback function. You never call it by yourself. Instead, grid will call it at appropriate time. So the parameters are passed into by grid, not you.
Logged
Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
anikitos
Jr. Member
Posts: 11
Re: Calculated columns
«
Reply #7 on:
August 13, 2008, 08:18:59 AM »
Thank you, this makes sense. And it works.
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> News & Announcements
-----------------------------
Sigma Visual GUI Builder & Library
-----------------------------
=> Sigma Visual - Knowledge Share
=> Sigma Visual - Q&A
=> Bug Report & Wishlist
-----------------------------
Sigma Grid
-----------------------------
=> Sigma Grid - Q&A
=> Show Case
=> Bug Report & Wishlist
-----------------------------
Other
-----------------------------
=> AJAX & JavaScript
Loading...