1. #1
    Sencha User
    Join Date
    Jun 2013
    Location
    Pune
    Posts
    6
    Vote Rating
    0
    amanjain is on a distinguished road

      0  

    Default Unanswered: Need Assistance in accessing child model properties in the XTemplate

    Unanswered: Need Assistance in accessing child model properties in the XTemplate


    Hi,

    I am a novice user of the GXT framework. I am stuck up in using XTemplate to access the data from a child model. Following is a brief of the exact problem :

    I have a parent model named RegulationModel. This parent model has a reference to another child model named RegulationDetailsModel.
    UI : Its Grid display with expander rows. XTemplate is used to generate the custom html to render the data whenever the user expands a row.


    Accessing the data from the parent model is quite straight forward but I am not able to access the data from the child model. The models extend from the com.extjs.gxt.ui.client.data.BaseModelData. Can anybody help me out in this ? Following is the snippet of the XTemplate :

    XTemplate tpl = XTemplate.create("<p><b>Secondary Citation:</b> <br>{" + RegulationModel.SECONDARYCITATION
    + "}</p><br>" + "<p><b>Description:</b> <br>{" + RegulationModel.DESCRIPTION + "}</p><br>"
    + "<p><b>Admin Requirement:</b> <br>{" + RegulationModel.ADMINREQUIREMENT + "}</p><br>"
    + "<p><b>Zasio Notes:</b> <br>{" + RegulationModel.REGULATIONDETAILS + "}</p><br>"
    + "<p><b>Create Date:</b> <br>{" + RegulationModel.CREATEDATESTRING + "}</p><br>"
    + "<p><b>Last Update Date:</b> <br>{" + RegulationModel.UPDATEDATESTRING + "}</p><br>"


    The above highlighted is the field (ZasioNotes) that I want to access from the child model i.e., RegulationDetailsModel. It is declared in the child model but I am not access it in the above context.

    Any pointers will help me a lot. I have used various things already but none worked. Like using the "tpl" tag , using the complete property name like RegulationModel.regulationDetails.ZasioNotes etc.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Answers
    109
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Your template seems to be using GXT 2, so I've moved the thread to the GXT 2 Q & A forum.

    Can you provide some details on the basic structure of RegulationModel and RegulationDetailModel? Your last statement seems to be correct - it should be possible to refer to something like {details.notes} to get access to object.getDetails().getNotes() or ((RegulationDetailModel)object.get("details")).get("notes"). If this isn't working correctly, we'll need details about how the object it set up, and how you are using that templates. The specifics of what RegulationModel.regulationDetails.ZasioNotes returns would also be helpful.

    Can you post those classes, or perhaps make a sample app that describes the basic idea you are after?

    You might also find this example helpful: http://www.sencha.com/examples-2/#templates. It shows referring to the parent's name inside the child object by calling it "parent.name". This isn't an apples-to-apples comparison with your case, but your model object will be accessible in roughly the same way.

  3. #3
    Sencha User
    Join Date
    Jun 2013
    Location
    Pune
    Posts
    6
    Vote Rating
    0
    amanjain is on a distinguished road

      0  

    Default


    I have attached the two model objects that I am using. The code snippet that I had pasted earlier is the one where I need specify the name of the properties from the child domain object i.e, RegulationDetailsModel

    Using the "for" property of the <tpl> tag seems to help in iterating through a collection from the child model object. But if I do not have a collection to iterate in the child model object, then how do I refer to the property from the child model object.

    Please let me know if more details are needed.

  4. #4
    Sencha User
    Join Date
    Jun 2013
    Location
    Pune
    Posts
    6
    Vote Rating
    0
    amanjain is on a distinguished road

      0  

    Default


    Any answers ?

  5. #5
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Answers
    109
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Any answers ?
    Unfortunately, I couldn't reply right away because I put up my post just before I went to bed. These are the Community forums, which means that community members will be answering as well as Sencha developers. If you need help right away, file a support ticket.


    I have attached the two model objects that I am using.
    I don't see any code at all, except for the bit with the xtemplate in the first post you made. Are you sure you attached them? Perhaps you can paste them inside of CODE tags?

    Using the "for" property of the <tpl> tag seems to help in iterating through a collection from the child model object. But if I do not have a collection to iterate in the child model object, then how do I refer to the property from the child model object.
    The 'for' property is only for collections, you don't need it to reference nested properties that aren't in a list.

  6. #6
    Sencha User
    Join Date
    Jun 2013
    Location
    Pune
    Posts
    6
    Vote Rating
    0
    amanjain is on a distinguished road

      0  

    Default


    Well I had initially uploaded the files but soon after I realized that I am not supposed to send out anything whatsover outside my organization as the Client is overly strict being into the financial vertical.

    Anyways following is a brief snippet of the Model classes:

    <CODE>
    public class RegulationDetailsModel extends BaseModelData implements IsSerializable, Serializable {
    ..............
    ..........
    public static final String ZASIONOTES = "zasioNotes";
    ..........
    ......

    public String getZasioNotes() {
    get(ZASIONOTES);
    }

    public void setZasioNotes(String zasioNotes) {
    set(ZASIONOTES, zasioNotes);
    }
    .............
    .......
    }
    </CODE>

    <CODE>
    public class RegulationModel extends BaseModelData implements IsSerializable, Serializable {
    ..............
    ................
    public static final String REGULATIONDETAILS = "regulationDetails";
    ............
    ...........
    // RegulationDetails is my domain object. I also have a domain object corresponding to the RegulationModel //which is Regulation.
    public RegulationDetails getRegulationDetails() {
    get(REGULATIONDETAILS);
    }
    public void setRegulationDetails(RegulationDetails regulationDetails) {
    set(REGULATIONDETAILS, regulationDetails);
    }
    .....................
    ................
    }
    </CODE>

    If the 'for' property is used only to refer to the nested list properties, then how do we get access to the nested non-list properties ? The snippet that I had posted in the first time of this post is the actual XTemplate custom html that i am using. Additionally, the property that you see in the code snippet above i.e., ZASIONOTES - this is the only field that I need render when I click on the 'plus' sign of my grid. Please check the first grid on this link :
    http://www.sencha.com/examples-2/#gridplugins - this is the one that I am using.

    Please do let me know if more details may be needed to give me some pointers on this.

  7. #7
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Answers
    109
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    If you can't share the files, then make up a sample project with sample models entirely unrelated to your real project, but demonstrating the basic structure.

    At a glance from your almost-java , it looks like you should be able to do this:
    Code:
    Zasio notes: {regulationDetails.zasioNotes}
    to indicate that you want it to invoke:
    Code:
    object.getRegulationDetails().getZasioNotes()
    Have you tried this? What does it do?

    Using your string concatenation approach, this will look a little like this:
    Code:
    //...
     + "<p><b>Zasio Notes:</b> <br>{" + RegulationModel.REGULATIONDETAILS + "." + RegulationDetailsModel.ZASIONOTES + "}</p><br>"
    //...

  8. #8
    Sencha User
    Join Date
    Jun 2013
    Location
    Pune
    Posts
    6
    Vote Rating
    0
    amanjain is on a distinguished road

      0  

    Default


    Thanks a lot for the answers. I need to try out this option as well, though I had tried the same thing in a different way which dint work out. Will try this for sure and update.

  9. #9
    Sencha User
    Join Date
    Jun 2013
    Location
    Pune
    Posts
    6
    Vote Rating
    0
    amanjain is on a distinguished road

      0  

    Default


    Though I had tried earlier as well multiple ways, I again tried the one you suggested and it did not work. It gives an errors saying that "com.google.gwt.core.client.JavaScriptException: (TypeError): 'regulationDetails' is undefined".
    I dont know why this simple and most expected scenario is not supported by the XTemplate. I have now changes the implementation by moving the fields from the child model to the parent model. I know this wont be accepted whenever my code will be reviewed.

  10. #10
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Answers
    109
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    (TypeError): 'regulationDetails' is undefined
    This means that the model passed in didn't have a field called regulationDetails, so it was impossible to read the zasioNotes property from it. Is it possible that this was left null (and so zasioNotes would be unreachable)?

    I'd like to be able to help - please post a runnable example of this demonstrating the issue so we can run it and see why it isn't working.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."