Sigma Php Ajax framework, Ajax Components, GUI Builder
May 23, 2012, 03:49:45 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Why not we help since it's open source?  (Read 363 times)
ionut1982
Newbie
*
Posts: 1


View Profile
« on: November 29, 2011, 12:09:07 AM »

Hello!
First of all, sorry for my poor english.

Here's attached gt_msg_ro.js for Romanian language and custom header with remote filtering.

index.php
Quote
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
 
<link rel="stylesheet" type="text/css" href="grid/gt_grid.css" />
<script type="text/javascript" src="grid/gt_msg_ro.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" >
<!-- All the scripts will go here -->
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}
       
];
Sigma.ToolFactroy.register(
    'rmfilter', 
    {   
      //in gt_grid.css add -> .remfilters-cls { background : url(./imgages/sc_removefiltersort.png) no-repeat center center; } //search online for sc_removefiltersort.png
        cls : 'remfilters-cls', 
        toolTip : 'Remove filters',
        action : function(grid) {  doUnfilter();  }
    }
);
var gridOption={
   id : "Employee",
   loadURL : "lista-sql.php",
   exportURL : 'export.php?export=true',
   exportFileName : 'test_export_doc',
   container : 'grid1_container',
   replaceContainer : true,
   dataset : dsOption ,
   columns : colsOption,
   customHead : 'myHead',
   onRowDblClick: function(value,record,cell,row,colNo,columnObj,grid){ document.location.href("http://127.0.0.1/details.php?id=" + record);},
   resizable: true,
   remoteSort:true,
   remoteFilter:true,
   remotePaging:true,
   toolbarContent : 'nav | goto | pagesize | print | filter | rmfilter | reload | xls state',
  pageSize : 20 ,
   pageSizeList : [5,10,15,20,30,40,50,100,150,200],
   autoLoad : false
};

var mygrid=new Sigma.Grid(gridOption);
Sigma.Utils.onLoad( function(){

   mygrid.render();
   mygrid.reload();
} );

 
</script>
</head>
  <script type="text/javascript" >
function handleKeyPress(e){
var key=e.keyCode || e.which;
if (key==13){
doFilter();
}
}
function doFilter() {
   var filterInfo=[
   {
      fieldName : "employee",
      logic : "startWith",
      value : Sigma.Util.getValue("employee")
   },
   {
      fieldName : "country",
      logic : "startWith",
      value : Sigma.Util.getValue("country")
   },
   {
      fieldName : "customer",
      logic : "startWith",
      value : Sigma.Util.getValue("customer")
   },
   {
      fieldName : "bill2005",
      logic : "startWith",
      value : Sigma.Util.getValue("bill2005")
   },
   {
      fieldName : "bill2006",
      logic : "startWith",
      value : Sigma.Util.getValue("bill2006")
   },
   {
      fieldName : "bill2007",
      logic : "startWith",
      value : Sigma.Util.getValue("bill2007")
   },
   {
      fieldName : "bill2008",
      logic : "startWith",
      value : Sigma.Util.getValue("bill2008")
   },

   {
      fieldName : "orderDate",
      logic : "startWith",
      value : Sigma.Util.getValue("orderDate")
   }
   ]
   
    var grid=Sigma.$grid("Employee");
    grid.applyFilter(filterInfo);
}
function doUnfilter(){
   var grid=Sigma.$grid("Employee");
   var rowNOs=grid.applyFilter([]);
 
}


</script>
 
<body>

<table id="myHead" style="display:none">
<tr>
   <td columnId='order_no'>order_no</td>
   <td columnId='employee'>employee</td>
   <td columnId='country'>country</td>
   <td columnId='customer'>customer</td>
   <td columnId='bill2005'>bill2005</td>
   <td columnId='bill2006'>bill2006</td>
   <td columnId='bill2007'>bill2007</td>
   <td columnId='bill2008'>bill2008</td>
   <td columnId='orderDate'>orderDate</td>   
</tr>
<tr>
   <td style= "width:60">&nbsp;</td>
   <td><input style= "width:80" type="text" id="employee" value="" onKeyUp="handleKeyPress(event);"></td>
   <td><input style= "width:70" type="text" id="country" value="" onKeyUp="handleKeyPress(event);"></td>
   <td><input style= "width:80" type="text" id="customer" value="" onKeyUp="handleKeyPress(event);"></td>
   <td><input style= "width:60" type="text" id="bill2005" value="" onKeyUp="handleKeyPress(event);"></td>
   <td><input style= "width:60" type="text" id="bill2006" value="" onKeyUp="handleKeyPress(event);"></td>
   <td><input style= "width:60" type="text" id="bill2007" value="" onKeyUp="handleKeyPress(event);"></td>
   <td><input style= "width:60" type="text" id="bill2008" value="" onKeyUp="handleKeyPress(event);"></td>
   <td><input style= "width:100" type="text" id="orderDate" value="" onKeyUp="handleKeyPress(event);"></td>
</tr>
</table>

<!-- grid container. -->
<div id="grid1_container" style="width:950px;height:400px">
</div>
 
 </body>
</html>

lista-sql.php
Quote
<?php
include("../connect.inc.php");                           //database connection
header("Content-Type:text/javascript; charset=utf-8");
$json=json_decode(stripslashes($_POST["_gt_json"]));         //decode our json post
$pageNo = $json->{'pageInfo'}->{'pageNum'};                  //our current page number
$pageSize = $json->{'pageInfo'}->{'pageSize'};                //rows per page

$order="";
if(!empty($json->{'sortInfo'})) {                         // if sortInfo array is not empty,
$fld = $json->{'sortInfo'}[0]->{'fieldName'};               // read the first element               (I only needed the first, but since is an array, you could do a for loop to read others)
$ord = $json->{'sortInfo'}[0]->{'sortOrder'};               
$order = "ORDER BY ".$fld." ".$ord;                      // and set the sql statement.
}

$uere="";                                          // Here begins WHERE clause for filtering statement.
$primul=0;                                          // primul=0 becouse the first element must be preceded by WHERE clause
if(!empty($json->{'filterInfo'})) {                        // if filterInfo array is not empty
$count=sizeof($json->{'filterInfo'});                     // see what size it has
for($j=0;$j<$count;$j++){                              // and loop throug filterInfo array
$camp = $json->{'filterInfo'}[$j]->{'fieldName'};            // read the field name for WHERE clause
$valo = $json->{'filterInfo'}[$j]->{'value'};               // and the value the field sould have
if ($valo != "") {                                     // if the value is not empty
               if($primul == 0){                      // and $primul is 0, then
                              $uere.= "WHERE ".$camp." LIKE '".$valo."%' "; $primul = 1; // Ad WHERE clause to first $camp LIKE '$valo%'
                           } else { $uere.= " AND ".$camp." LIKE '".$valo."%' ";}          // ELSE just add AND $camp LIKE '$valo%'
            }
      }
}                                                      /* NOTE I used LIKE % in where clause becouse I only filtered from custom header (see index.php) using startWith logic value... but
                                                         you could take use of $logic = $json->{'filterInfo'}[$j]->{'logic'};  and make something like $uere.= " AND ".$camp.$logic."'".$valo."%'
                                                      Of course, you must replace the logic using case or if function with the sql correct operators.
                                                      */


$sql = "select count(*) as cnt from orders ".$uere;
$handle = mysql_query($sql);
$row = mysql_fetch_object($handle);
$totalRec = $row->cnt;
//make sure pageNo is inbound
if($pageNo<1||$pageNo>ceil(($totalRec/$pageSize))){
  $pageNo = 1;
}

//pageno starts with 1 instead of 0
$sql = "select * from orders ".$uere." ".$order." limit " . ($pageNo - 1)*$pageSize . ", " . $pageSize;
$handle = mysql_query($sql) or die(mysql_error());   
$retArray = array();
while ($row = mysql_fetch_row($handle)) {
  $retArray[] = $row;
}


$data = json_encode($retArray);
$ret = "{data:" . $data .",\n";
$ret .= "pageInfo:{totalRowNum:" . $totalRec . "},\n";
$ret .= "recordType : 'array'}";
echo $ret;



?>


qt_msg_ro.js
Quote
//

if (!window.Sigma){
   window.Sigma={};
}
Sigma.Msg=Sigma.Msg || {};
SigmaMsg=Sigma.Msg;

Sigma.Msg.Grid = Sigma.Msg.Grid || {};

Sigma.Msg.Grid.ro={
   LOCAL   : "RO",
   ENCODING      : "UTF-8",
   NO_DATA : "Nicio inregistrare",


   GOTOPAGE_BUTTON_TEXT: 'Mergi la',

   FILTERCLEAR_TEXT: "Sterge toate filtrele",
   SORTASC_TEXT   : "Crescator",
   SORTDESC_TEXT   : "Descrescator",
   SORTDEFAULT_TEXT: "Original",

   ERR_PAGENUM      : "Numarul pagini trebuie sa fie nr intreg intre 1 si #{1}.",

   EXPORT_CONFIRM   : "Aceasta operatie va afecta toate inregistrarile ale intregului tabel.\n\n( Apasa \"Anulare\" pentru a aplica doar pe pagina curenta.)",
   OVER_MAXEXPORT   : "Numarul de inregistrari depaseste #{1}, numarul maxim permis.",

   PAGE_STATE   : "#{1} - #{2} afisate,  #{3} pagini si #{4} inregistrari in total.",
   PAGE_STATE_FULL   : "Pagina #{5}, #{1} - #{2} afisate,  #{3} pagini si #{4} inregistrari in total.",

   SHADOWROW_FAILED: "Nu sunt disponibile informatii relevante",
   NEARPAGE_TITLE   : "",
   WAITING_MSG : 'Rog asteptati...',

   NO_RECORD_UPDATE: "Nimic modificat",
   UPDATE_CONFIRM   : "Sigur vrei sa salvezi?",
   NO_MODIFIED: "Nimic modificat",

   
   PAGE_BEFORE : 'Pagina',
   PAGE_AFTER : '',

   PAGESIZE_BEFORE :   '',
   PAGESIZE_AFTER :   'Pe pagina',

   RECORD_UNIT : '',
   
   CHECK_ALL : 'Bifeaza tot',

   COLUMNS_HEADER : 'Coloane',

   DIAG_TITLE_FILTER : 'Optiuni filtru',
   DIAG_NO_FILTER : 'Niciun filtru',
   TEXT_ADD_FILTER   : "Adauga",
   TEXT_CLEAR_FILTER   : "Sterge tot",
   TEXT_OK   : "OK",
   TEXT_DEL : "Sterge",
   TEXT_CANCEL   : "Anuleaza",
   TEXT_CLOSE   : "Inchide",
   TEXT_UP : "Sus",
   TEXT_DOWN : "Jos",

   NOT_SAVE : "Vrei sa salvezi modificarile? \n Click \"Anuleaza\" pentru a nu salva.",

   DIAG_TITLE_CHART  : 'Grafic',

   CHANGE_SKIN : "Skins",

   STYLE_NAME_DEFAULT : "Classic",
   STYLE_NAME_PINK : "Pink",
   STYLE_NAME_VISTA : "Vista",
   STYLE_NAME_MAC : "Mac",

   MENU_FREEZE_COL : "Blocheaza Coloane",
   MENU_SHOW_COL : "Ascunde coloane",
   MENU_GROUP_COL : "Group Span",

   TOOL_RELOAD : "Reincarca" ,
   TOOL_ADD : "Adauga" ,
   TOOL_DEL : "Sterge" ,
   TOOL_SAVE : "Salveaza" ,

   TOOL_PRINT : "Imprima" ,
   TOOL_XLS : "Exporta ca xls" ,
   TOOL_PDF : "Exporta ca pdf" ,
   TOOL_CSV : "Exporta ca csv" ,
   TOOL_XML : "Exporta ca xml",
   TOOL_FILTER : "Filtru" ,
   TOOL_CHART : "Grafic"

};

Sigma.Msg.Grid['default']=Sigma.Msg.Grid.ro;


if (!Sigma.Msg.Validator){
   Sigma.Msg.Validator={ };
}

Sigma.Msg.Validator.ro={

      'required'   : '{0#This field} e obligatoriu.',
      'date'      : '{0#This field} trebuie sa aiba formatul corespunzator ({1#YYYY-MM-DD}).',
      'time'      : '{0#This field} trebuie sa aiba formatul corespunzator ({1#HH:mm}).',
      'datetime'   : '{0#This field} trebuie sa aiba formatul corespunzator ({1#YYYY-MM-DD HH:mm}).',
      'email'      : '{0#This field} trebuie sa fie in format email.',
      'telephone'   : '{0#This field} trebuie sa fie in formatul numarului de telefon.',
      'number'   : '{0} trebuie sa fie mumar.',
      'integer'   : '{0} trebuie sa fie intreg.',
      'float'      : '{0} trebuie sa fie intreg sau zecimal.',
      'money'      : '{0} trebuie sa fie intreg sau cu 2 zecimale.',
      'range'      : '{0} trebuie sa fie intre {1} si {2}.',
      'equals'   : '{0} trebuie sa fie la fel ca {1}.',
      'lessthen'   : '{0} trebuie sa fie mai mic decat {1}.',
      'idcard'   : '{0} trebuie sa aiba formatul ID corespunzator',

      'enchar'   : 'Litere, cifre sau underscore permise doar pentru {0}',
      'cnchar'   : '{0} trebuie sa fie caractere chinezesti',
      'minlength'   : '{0} trebuie sa contina mai mult de {1} caractere.',
      'maxlength'   : '{0} trebuie sa contina mai putin de {1} charactere.'

}

Sigma.Msg.Validator['default'] = Sigma.Msg.Validator.ro;

//
« Last Edit: December 03, 2011, 10:38:33 AM by ionut1982 » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!