Finding out if any modifications are being made in thefields in an editable datagrid

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default Finding out if any modifications are being made in thefields in an editable datagrid

    Hi,
    I populated my data grid with an array
    collection(initDG=event.result.categorydtls.catego ry) where initDGObject is the
    array collection.I made the data grid as editable.Now , when the user click's
    on submit(below data grid), the request for modifying the corresponding details
    in database should go only if the user makes any modification ,or else an alert
    should be shown saying that "you havent made any modifications".For this
    purpose i assigned "event.result.categorydtls.category" to another array
    collection initDGObject and ,in the function which will be invoked after
    clicking on submit i compared both the objects initDG and initDGObject.But to
    my surprise,if any field in data grid is modified then both initDG and
    intiDGObject(here let me remind that i assigned initDG as the data provider for
    grid and initDGObject is a normal array collection object for which the details
    are assigned to for comparison purpose) are also modifying.So i am unable to
    check if any modifications are being made before forwarding request for
    database modification to back end.Please suggest me a solution for doing this
    task.Thanks in advance.

    //Function for populating datagrid
    public function subcategoriesResults(event:ResultEvent):void {
    Alert.show("Iam in the result handler for getDetails");
    //var res:String;
    var xArray:Array;
    objCat=null;
    initDG=null;
    try
    {

    //Alert.show("Value is:"+event.message.body.toString());
    initDGObject=event.result.categorydtls.category;
    initDG=event.result.categorydtls.category;
    subCategories.dataProvider=initDG;
    }
    catch(error:Error){

    //Alert.show("Sorry you have no subcategories");
    try{
    objCat=event.result.categorydtls.category;
    objToCheck=objCat;
    subCategories.dataProvider=objCat;
    }
    catch(error:Error){
    Alert.show("Sorry you have no subcategories");
    subCategories.dataProvider=null;
    }

    }

    }
    //Function which checks if any modifications are done and forwards request
    based on that
    public function updateSubCategory():void {
    var msg:String = "";
    var flag:Number=0;
    if(initDG != null){
    if(initDG.length>1){
    //Alert.show("the message is here");
    var
    check:int=ObjectUtil.compare(initDGObject,subCateg ories.dataProvider,0);//comapr
    ing the two arraycollection objects
    Alert.show(check.toString());
    if(check!=0)
    {
    for (var i:Number=0; i<initDG.length; i++)
    {

    if(initDG[i].catg_status=="I" || initDG[i].catg_status=="A")
    {
    msg += initDG[i].catg_name + "," + initDG[i].catg_desc+"," +
    initDG[i].catg_status+","+initDG[i].catg_id+"#";
    }
    else
    {
    Alert.show("I(Inactive) and A(Active) are the only characters allowed for
    the category status");
    getDetails(storeParent);
    return;
    }

    }
    }
    else
    {
    Alert.show("Please edit the category details before clicking on
    Submit");
    return;
    }
    }
    }
    else if(objCat!=null)
    {
    if((objToCheck.catg_name==objCat.catg_name) &&
    (objToCheck.catg_desc==objCat.catg_desc) &&
    (objToCheck.catg_status==objCat.catg_status))
    {
    Alert.show("Please edit the topic details before clicking on submit");
    return;
    }
    if(objCat.catg_status=="I" || objCat.catg_status=="A")
    msg += objCat.catg_name + "," + objCat.catg_desc+"," +
    objCat.catg_status+","+objCat.catg_id+"#";
    else
    {
    Alert.show("I(Inactive) and A(Active) are the only characters allowed for
    the category status");
    getDetails(storeParent);
    return;
    }
    }
    //Alert.show("Message is"+msg);
    var objParams:Object = new Object ();
    objParams.msg=msg;
    subCategoriesUpdateServ.url=subCatUrl+"?submit=upd ate";
    subCategoriesUpdateServ.send(objParams);
    //Alert.show("msg========="+msg);
    }

    kchamarthi Guest

  2. Similar Questions and Discussions

    1. DataGrid EditItemCommand : must click twice to make DataGrid Editable
      Hey- I am having trouble with a simple datagrid example, and need some advice if anyone is knowledgable. It's really driving me batty! I've...
    2. Making editable datagrid.
      Hi all i am new to asp.net. i have one application where i am filling value from database to datagrid. What i want is whenever user click on...
    3. Editable Datagrid
      I have a challenge, that I do not seem to be able to solve. I have an "overview"-page that presently displays data from 2 columns in a database...
    4. Editable rows....... for datagrid....
      Does anybody point me to datagrid sample with editable cell ? rudy
    5. DataGrid / FDataGrid modifications
      Hello Flashers, I've posted some modifications to the FDataGrid component that some might be interested in. Unfortunately, it's not free, but it...
  3. #2

    Default Re: Finding out if any modifications are being made inthe fields in an editable datagrid

    [url]http://blog.paranoidferret.com/index.php/2007/08/24/flex-php-json-mysql-advanced-updating/[/url]

    Essentially, you'll be listening for collection change event for your collection.

    ATTA
    atta707 Guest

  4. #3

    Default Re: Finding out if any modifications are being made inthe fields in an editable datagrid

    Thanks for that reply..It worked when the datagrid is populated with an array
    collection...but when the datagrid is populated with an object(which is the
    case when a single record is to be displayed in datagrid)it is not possible
    since we cant add an event listener for an object.Please suggest me a solution.

    kchamarthi Guest

  5. #4

    Default Re: Finding out if any modifications are being made inthe fields in an editable datagrid

    You could always add that single object into a array collection. That's what, by the way, what data grid does for you implicitly.

    ATTA
    atta707 Guest

  6. #5

    Default Re: Finding out if any modifications are being made inthe fields in an editable datagrid

    lam not able to add a single object to the array collection.Regarding the usage
    of datagrid in my task,there will be a drop down on the top of datagrid with
    categories(like science,maths...)in it.Whenever a particular category is
    selected then the corresponding subcategories(in category science sub
    categories are physics,biology.....)details will be populated in the
    datagrid.Please suggest me a solution.

    kchamarthi Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139