Hybrid View

  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,634
    Answers
    107
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      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,634
    Answers
    107
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      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.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar