开发者

JQGrid and CakePHP

开发者 https://www.devze.com 2023-02-09 08:47 出处:网络
I have a JQGrid with a total of three columns and am populating the tables using the framework cakephp.One of the columns is the id(uneditable). The other two are first name and last name. It is readi

I have a JQGrid with a total of three columns and am populating the tables using the framework cakephp. One of the columns is the id(uneditable). The other two are first name and last name. It is reading/adding/deleting records from a mysql database just fine. However, when I go to edit a cell in JQgrid, it saves the changes to the cell I am editing, but it erases the data from the other.

For example, if I 开发者_StackOverflow中文版have a record with an id of 1, firstname of bob and last name of john. I go to edit the last name and change it to smith. The record now shows 1 Bob Smith. When I refresh the page, the record shows up as '1 "" Smith'. Any ideas? My code for the indexedit in my controller is as follows (and thank you in advance):

function indexedit()
        {        

            //$this->layout= 'empty';   
            $this->autoRender = false;
            $action = $this->params["form"]["oper"];
                    if($action=="edit")
                    {
                        $id=$this->params["form"]["id"];    
                        $fName = $this->params["form"]["firstname"];
                        $lName = $this->params["form"]["lastname"];
                        $this->Apple->save(Array("id"=>$id,"firstname"=>$fName,"lastname"=>$lName),null);

                    }

                    if($action=="del")
                    {

                        $id=$this->params["form"]["id"];

                        //For Multiple Deletion
                        $exploded_id = explode(',', $id);

                        for($i=0;$i<sizeof($exploded_id);$i++)
                        {
                            $this->Apple->delete($exploded_id[$i]); 


                        //  $fileDir = WWW_ROOT .'img/newsroom/press/'.$id;
                        //  $this->removeFolder($fileDir);


                        }
                        //For Multiple Deletion


                        //single deletion :  
                        //$this->Apple->delete($id);        

                    }

                    if($action =="add")
                    {
                        $fName = $this->params["form"]["firstname"];
                        $lName = $this->params["form"]["lastname"];

                        $this->Apple->save(Array("firstname"=>$fName,"lastname"=>$lName),null,null);                             
                    }


Just a thought: try putting $this->Apple->create(); before the save() statements.

0

精彩评论

暂无评论...
验证码 换一张
取 消