开发者

In ExtJS, How can I list multiple returns from JSON data in a field set?

Ok, I am semi-new to ExtJS, and I am building a program that has "inputs" that are listed in a grid, and in my DB these inputs can be linked to "symptoms".

I am trying to create a functio开发者_如何学编程n that will take in the id of the input and grab all of the symptoms from the database that are linked to that symptom, and list them in a field set.

It works fine when I click on an input that is only linked to one symptom, but if the input is linked to more than one symptom, then the error says.. "invalid property id"

This is what I have for my function.

function listSymptoms(inputID){
    Ext.Ajax.request({
        url: "../../inc/project4.php?list=symptoms",
        reader: new (Ext.data.JsonReader)({
            root: "symptoms",
            inputid: "id"
        }),
        params: {
            inputid: inputID
        },
        method: "POST",
        success: function (f, a){
            var jsonData = Ext.util.JSON.decode(f.responseText);
            symptomsFieldSet.body.update(jsonData.data.name);
        },
        failure: function (f,a){
            Ext.Msg.alert('There was a problem opening your message.');
        }
    });
}

I have the inputID for the function being passed in when the user clicks on one of the inputs that are held inside the grid.

I believe that my problem has something to do with this line..

  symptomsFieldSet.body.update(jsonData.data.name);

I am just stumped on how to handle this. Do I need to create a data store like I have for grids? Or is there an easier way to do this?

ANY help is appreciated! thanks in advance.


I think you need to rethink the structure of your JSON response object. You can send this in your JSON response to your request. If you are using Ext.util.Ajax calls instad of a form, you'll need to decode this JSON response string using the util method Ext.util.JSON.decode(). Check out the API Documentation

{
  success: true,
  msg: {text: 'this can be used for error message handling' },
  data : [
          {id:1,
           chiefComplaint: 'head hurts',
           symptoms: [
                 {symptomID: '740.1', text: 'Headache'},
                 {symptomID: '12352135'. text: 'and so on'}
           }
         ]
  ]
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜