Select to view content in your preferred language

Editing a related table -help- esri sample

1019
11
11-07-2011 04:24 AM
LizDaRos
Regular Contributor
Hi, I was wondering if anyone has used the sample from esri that allows you to edit a related table? I have the application setup and running using one of my own feature services but I need to add more fields from the related table to edit. This sample only allows you to make edits to the agree_with_incident field by clicking on an image. I'm not sure where I need to add in my others fields that I'd like to edit.
Any ideas would greatly be appreciated!
Tags (2)
0 Kudos
11 Replies
LizDaRos
Regular Contributor
I've found some code that uses the same code as the attribute inspector sample to edit related tables. Here is the link-
access-a-relationship-query-through-Attribute-Inspector
I'm also using points instead of polygons so I've switched some on the code in the attribute inspector sample to select the points.
I think I am close to getting this working, I can see the related table information in the attribute inspector popup but it only shows for about half a second then disappears and another blank popup displays.
Attached is my code... can anyone see what the problem is?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Liz,

   Your issue is that both the roomsLayer and the roomsTableLayer featurelayers are firing the tableSelect_selectionCompleteHandler function.
0 Kudos
LizDaRos
Regular Contributor
That was it, thank you very much Robert!
Now I just need to add a function that adds a new record to the related table. It looks like the code from the Editing a Related Table sample can do this. If that's the right direction then I'm trying to use this function in my application but not having much luck. Any suggestions?

   private function addImage_clickHandler(event:MouseEvent):void
   {
    const roomsTableLayer:Object = {
     object: selectedGraphic.attributes.objectid,
      datetime: new Date().getTime(),
      agree_with_incident: 1
    };
    const roomsTableLayer:Graphic = new Graphic(null, null, roomsTableLayerAttributes);
   
    const roomsTableLayer:FeatureLayer = new FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/1");
    roomsTableLayer.addEventListener(FeatureLayerEvent.EDITS_COMPLETE, roomsTableLayer_editsCompleteHandler);
    roomsTableLayer.applyEdits([ voteRecord ], null, null);
   }
   private function roomsTableLayer_editsCompleteHandler(event:FeatureLayerEvent):void
   {
    count++;
    peopleCount.text = count + " people think this is important";
   }
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Liz,

    You have several coding issue here:

private function addImage_clickHandler(event:MouseEvent):void
{
    const roomsTableLayer:Object = {
    object: selectedGraphic.attributes.objectid,
    datetime: new Date().getTime(),
    agree_with_incident: 1
    };

   //And here you are using the same constant name again, this is no good.
    const roomsTableLayer:Graphic = new Graphic(null, null, roomsTableLayerAttributes);

    //And here you are using the same constant name again, this is really no good.
    const roomsTableLayer:FeatureLayer = new FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/1");
    roomsTableLayer.addEventListener(FeatureLayerEvent.EDITS_COMPLETE, roomsTableLayer_editsCompleteHandler);
    //Now you are trying to apply voteRecord which does not exist in your code to the table
    roomsTableLayer.applyEdits([ voteRecord ], null, null);
}

private function roomsTableLayer_editsCompleteHandler(event:FeatureLayerEvent):void
{
    count++;
    peopleCount.text = count + " people think this is important";
}
0 Kudos
LizDaRos
Regular Contributor
Thanks for looking at it. I guess I was just wondering if the function from that sample would even do what I want? I kind of realized the code I showed wasn't correct and would need some changes.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Liz,

   It looks like it should work.
0 Kudos
R__CraigHolmes
Emerging Contributor
Thanks for looking at it. I guess I was just wondering if the function from that sample would even do what I want? I kind of realized the code I showed wasn't correct and would need some changes.


Greetings Liz,
I am having difficulty with the final step of adding an additional relate entry.  Did you you have success with this?
Can you share your code?
Craig
0 Kudos
LizDaRos
Regular Contributor
Craig,
No I wasn't able to add an additional relate entry with this flex sample, sorry. Instead I used the Javascript API sample- Citizen Service Request.
I was able to change this sample to just allow the user to create a new record in the related table.
Liz
0 Kudos
ionarawilson1
Deactivated User
Liz,

I am having a similar issue. Do you think you can share your code to add records to the related table? Thank you!
0 Kudos