Ext:前台js往gridpanel动态添加记录

stor:

<ext:Store ID="StorePutInImg" runat="server">

        <Reader>

            <ext:JsonReader IDProperty="PicName">

                <Fields>

                    <ext:RecordField Name="PicName">

                    </ext:RecordField>

                    <ext:RecordField Name="PicFileName">

                    </ext:RecordField>

                    <ext:RecordField Name="CreateTime">

                    </ext:RecordField>

                    <ext:RecordField Name="PicMark">

                    </ext:RecordField>

                </Fields>

            </ext:JsonReader>

        </Reader>

    </ext:Store>

js:

 var picToTempGridPanel = function () {

              var store = new Ext.data.ArrayStore({

                  autoDestroy: true,

                  fields: [{

                      name: 'PicName'

                  },

                {

                    name: 'PicFileName'

                },

                {

                    name: 'CreateTime'

                },

                {

                    name: 'PicMark'

                }]

              });

              var defaultData = {

                  PicName: txtpocName.getValue(),

                  //PicFileName: picFilePath.getValue(),



                  CreateTime: '20121010',

                  PicMark: txImgMark.getValue()

              };

              //alert(Ext.encode(defaultData));

              StorePutInImg.loadData(defaultData, true); //原型loadData( data, [append] )追加方式

             

          }

 

stor中最主要的一行:

<ext:JsonReader IDProperty="PicName">
这个字段必须要在添加的记录行里面赋值,不然添加记录会失败!

另外,设置了IDProperty="PicName",Ext会根据PicName来判断记录是不是相同,相同的话则不会往stor里面添加。

你可能感兴趣的:(gridPanel)