Sigma Php Ajax framework, Ajax Components, GUI Builder
May 21, 2012, 08:19:27 PM *
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] 2
  Print  
Author Topic: NO_MODIFIED  (Read 4672 times)
asherw
Full Member
***
Posts: 27


View Profile
« on: March 23, 2009, 11:54:04 AM »

Can we set the value of NO_MODIFIED? I need to save selected rows to another grid (database) using the built-in toolbar save button (even though no changes in the values of the cells). Save does not work unless something is changed (it will say "nothing modified").

Thanks,
Asher
Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #1 on: March 23, 2009, 12:01:42 PM »

You want to change what the message Says?

Change it in the language file.

For English is gt_msg_en.js
Logged
asherw
Full Member
***
Posts: 27


View Profile
« Reply #2 on: March 23, 2009, 12:09:49 PM »

Thanks for the reply.

No, I do not want to change the message. I want to set the value (to false or true) so when the toolbar save button is clicked it will trigger the save function (action == 'save').

Maybe it's not possible but I would like to use the built-in toolbar buttons (for save, delete, so on) and just modify my (save, delete, so on) scripts for different grid operations.

Thanks again,
Asher
Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #3 on: March 23, 2009, 01:47:53 PM »

So you want to have a "save" button to save the information to another grid?

It should be easy if you follow the Tool Factory example:
http://www.sigmawidgets.com/products/sigma_grid2/demos/example_customized_button.html


NO_MODIFIED is a constant used for the message "nothing modified". setting that to blank or null will simply show an empty alert box I would think. I haven't looked at the code for that. But if you even remove the alert box, that will not save it to a different grid, it will only do nothing. You will need to create a custrom button like in the example I showed you above.
Logged
asherw
Full Member
***
Posts: 27


View Profile
« Reply #4 on: March 23, 2009, 06:01:56 PM »

Thanks, Humi.

I implemented the Tool Factory example and it works. The only problem is, the button itself is not visible on the toolbar (but if you hover over it, the tooltip shows). And if you click it, it works. I tried different gif files (even the ones comes with Sigma - add, delete buttons, so on) and it still doesn't show the button... just the placeholder. I created my own too using Paint and same results. Any ideas?

Thanks again,
Asher
Logged
asherw
Full Member
***
Posts: 27


View Profile
« Reply #5 on: March 23, 2009, 06:58:39 PM »

Sorry for the double posts.

How can we make it so that when the user click the new button it will call the same controller.php file and based on action (i.e. action=='save' or action=='load' or action=='xxxx') takes the necessary action?

Is that possible?

Thanks,
Asher
Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #6 on: March 24, 2009, 04:11:01 AM »

Yes.

Make a user parameter for this when you click the button. then do what you want with the grid.

example
Logged
asherw
Full Member
***
Posts: 27


View Profile
« Reply #7 on: March 24, 2009, 05:23:12 AM »

Ok, but how do we call the php function (where do we put that)?

Thanks, Asher
Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #8 on: March 24, 2009, 05:31:17 AM »

When you go the Tool Factory Custom Toolbar button example:

Logged
asherw
Full Member
***
Posts: 27


View Profile
« Reply #9 on: March 24, 2009, 06:19:55 AM »

Here is my code:

...
...

<style type="text/css">
.mybutton-upd {
  background : url(./grid/skin/default/images/upd.gif) no-repeat center center;
}
</style>

var dsOption={
  fields : [
  {name : 'checkbox'},
  {name : 'prod_id'},
  {name : 'prod_name'},
  ...
  ...
  ...
  ],
  recordType : 'object'
};


var colsOption=[
  {id: 'checkbox', isCheckColumn : true },
  {id: 'prod_id' , header: "Product ID" , width :190, editor:{type:"text"}},
  {id: 'prod_name' , header: "Product Name" , width :190, editor:{type:"text"}},
  ...
  ...
  ...
];

Sigma.ToolFactroy.register(
  'mybutton',
  {
    upd : 'mybutton-upd',
    toolTip : 'Update',
    //this is where i call the update php file
    action : function(event,grid) { 'usupdate.php' }
  }
);

var gridOption={
  id : "grid1",
  loadURL : 'usaddprods.php',
  saveURL : 'usaddprods.php',
  container : 'grid1_container',
  dataset : dsOption,
  columns : colsOption,
  editable : true,
  clickStartEdit : true,
  selectRowByCheck: true,
  pageSize : 20,
  toolbarContent : 'nav | pagesize | goto | reload | mybutton filter state',
  pageSizeList : [5,10,20,50,100]
};

var mygrid=new Sigma.Grid(gridOption);
Sigma.Util.onLoad( Sigma.Grid.render(mygrid) );

...
...


When I click on mybutton, nothing happens (no error).

Thanks,
Asher
Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #10 on: March 24, 2009, 07:57:09 AM »

the Action of the button is not doing anything.

What is 'usupdate.php' ?
Logged
asherw
Full Member
***
Posts: 27


View Profile
« Reply #11 on: March 24, 2009, 08:38:54 AM »

Similar to controller.php... to save (not load) the selected rows to another database.

Here is the code...

<?php
session_start();
$dbname = $_SESSION[dbname];
header('Content-type:text/javascript;charset=UTF-8');

$json=json_decode(stripslashes($_POST["_gt_json"]));

  mysql_connect("localhost", "xxxxxx", "xxxxxxx");
  mysql_select_db(strtolower($dbname));

  //save selected data (rows) to database ($dbname)
  $selectedRecords = $json->{'selectedRecords'};
  foreach ($selectedRecords as $value){
    $str = "id='" . $value->id . "',";
    $str = $str . " prod_id='" . $value->prod_id . "',";
    $str = $str . " prod_name='" . $value->prod_name . "',";
    ...
    ...
    ...
    $sql = "insert into products set " . $str;
    if(mysql_query($sql)==FALSE){
      $errors .= mysql_error();
    }
  }

?>


This file is similar to controller.php (which I called mine usaddprods.php) to load and save the database. But in this case I have to create a new php file cuz I want the selected rows to be saved in a different database - not the one that's loaded.

Hope it makes sense.

Thanks,
Asher
Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #12 on: March 24, 2009, 10:28:00 AM »

Maybe you are confused.

You need to tell the grid to save. And you have to tell it to save for it to POST the updated/deleted/inserted record to the controller. You can use the same controller.php as normal load/save operations (if you do) but have a conditional in the controller to check your custom "Action" parameter (myAction in example.)

This is how the code for the custom button should look.


Now in controller, make the conditional:


Maybe a little confusing. If you have trouble, we can walk through the save process.
Logged
asherw
Full Member
***
Posts: 27


View Profile
« Reply #13 on: March 24, 2009, 10:36:25 AM »

Thanks, Humi. I must misunderstood your replies and previous posts (about parameters). I will try it and post back here with the results. You've been very helpful.

Thanks again,
Asher
Logged
asherw
Full Member
***
Posts: 27


View Profile
« Reply #14 on: March 24, 2009, 11:04:35 AM »

I got the message "Nothing Modified". I guess when nothing changed, the controller is not even called... nothing to save? The function grid.save() probably check first if there is anything modified prior to calling the controller. Can we bypass that?

Asher
Logged
Pages: [1] 2
  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!