1 Reply Latest reply on Aug 6, 2014 8:33 AM by kglad

    How to make the datagrid data organised

    Beginning

      I am not sure what code that can make the data in datagrid in position like regid,regname,,address,email,phone,company rather than every time I go in,it will refresh and be in random position and it is not organised.

      Please help and please tell me where to put the code.

       

      package {

        import flash.display.MovieClip;

        import fl.events.*;

        import flash.events.*;

        import flash.net.NetConnection;

        import flash.net.Responder;

        import RecordSetDP;

       

        public class RegistrationAdmin extends MovieClip {

        private var gateway: String = "http://localhost:8088/amfphp/gateway.php";

        private var connection: NetConnection;

        private var refreshResponder: Responder;

        private var updateResponder: Responder;

        private var regid: int;

       

        public function RegistrationAdmin () {

        viewBtn.addEventListener (MouseEvent.CLICK, viewRegistrants);

        updateBtn.addEventListener (MouseEvent.CLICK, updateRegistrant);

        deleteBtn.addEventListener (MouseEvent.CLICK, deleteRegistrant);

        addBtn.addEventListener (MouseEvent.CLICK, addRegistrant);

        updateResponder = new Responder (refreshData, onFault);

        refreshResponder = new Responder (refreshSuccess, onFault);

        connection = new NetConnection ();

        connection.connect (gateway);

        registrantsDG.addEventListener (Event.CHANGE, gridItemSelected);

        refreshData (true);

        }

       

        public function viewRegistrants (e: MouseEvent): void {

        refreshData (true);

        }

       

       

        private function refreshData (refresh: Boolean): void {

        if (refresh)

        connection.call ("RegistrantService.viewRegistrants", refreshResponder);

        }

       

        private function refreshSuccess (result: Object): void {

        registrantsDG.dataProvider = RecordSetDP.toDataProvider (result);

        }

       

        private function onFault (fault: Object): void {

        trace (String (fault.description));

        }

       

        private function gridItemSelected (e: Event): void {

        regid = e.target.selectedItem.regid;

        regnameTxt.text = e.target.selectedItem.regname;

        addressTxt.text = e.target.selectedItem.address;

        phoneTxt.text = e.target.selectedItem.phone;

        emailTxt.text = e.target.selectedItem.email;

        companyTxt.text = e.target.selectedItem.company;

        }

       

        private function getParams () {

        var param: Object = new Object ();

        param.regid = regid;

        param.regname = regnameTxt.text;

        param.address = addressTxt.text;

        param.phone = phoneTxt.text;

        param.email = emailTxt.text;

        param.company = companyTxt.text;

        return param;

        }

       

        private function updateRegistrant (e: MouseEvent): void {

        var param: Object = getParams ();

        connection.call ("RegistrantService.updateRegistrant", updateResponder, param.regid, param.regname, param.address, param.phone, param.email, param.company);

        }

       

        private function deleteRegistrant (e: MouseEvent): void {

        var param: Object = getParams ();

        connection.call ("RegistrantService.deleteRegistrant", updateResponder, param.regid);

        }

       

        private function addRegistrant (e: MouseEvent): void {

        var param: Object = getParams ();

        connection.call ("RegistrantService.addRegistrant", updateResponder, param.regname, param.address, param.phone, param.email, param.company);

        }

        }

      }