[CLOSED] Adding New Record at run time

  1. #1

    [CLOSED] Adding New Record at run time

    Hi,
    I am trying to add record in Grid at runtime through extjs, It is added with no problem but when i want to post the Grid values as parameter using this code.

    Ext.encode(#{GridPanel_Categories}.getRowsValues({selectedOnly : false}))
    It gives error "record.fields is undefined" in firebug

    To add record in a store I am using this Code

    var rec = new Ext.data.Record({ ICategory: ISelectedCategory, Name: KnowledgeBase._SelectedCategoryName, ParentCategory: KnowledgeBase._SelectedCategoryParentName});
    store.add(rec);
    My Store is as follows

    <ext:Store ID="store_Categories" runat="server" IDMode="Static">
                                                <Proxy>
                                                    <ext:HttpProxy Json="true" Method="POST" Url="/KnowledgeBase/getCategoriesByKnowledgeBaseID" />
                                                </Proxy>
                                                <Reader>
                                                    <ext:JsonReader IDProperty="ICategory" Root="rows">
                                                        <Fields>
                                                            <ext:RecordField Name="ICategory" Type="String" SortDir="ASC" />
                                                            <ext:RecordField Name="Name" Type="String" />
                                                            <ext:RecordField Name="ParentCategory" Type="String" />
                                                        </Fields>
                                                    </ext:JsonReader>
                                                </Reader>
                                                <BaseParams>
                                                    <ext:Parameter Name="limit" Value="15" Mode="Raw" />
                                                    <ext:Parameter Name="start" Value="0" Mode="Raw" />
                                                    <ext:Parameter Name="dir" Value="ASC" />
                                                    <ext:Parameter Name="sort" Value="Id" />
                                                    <ext:Parameter Name="KnowledgeBaseID" Value="KnowledgeBase.getId()" Mode="Raw" />
                                                </BaseParams>
                                            </ext:Store>
    Last edited by Daniil; Feb 27, 2012 at 12:18 PM. Reason: [CLOSED]
  2. #2
    Hi,

    The correct way to add a record in ExtJS is using the Store recordType:
    http://docs.sencha.com/ext-js/3-4/#!...rty-recordType

    In Ext.NET you can use the GridPanel or Store addRecord/insertRecord methods.

    Example
    GridPanel1.addRecord({
        field1 : "field1 value",
        field2 : "field2 value"
    });
  3. #3
    hi Daniil,
    Thanks for Help, I have find the problem, I am passing some null values in Record fields which are giving error,

    By the way, I tried solution given by you, By using the following code.

    GridPanel1.addRecord({
        field1 : "field1 value",
        field2 : "field2 value"
    });
    Record added and rendered successfully without command column,

    I used the following code for this.

    var data = {
                        ICategory: this.getISelectedCategory(),
                        Name: this.getSelectedCategoryName(),
                        ParentCategory: this.getISelectedCategoryParentName()
                    };
                    var p = new store.recordType(data, this.getISelectedCategory);
                    grid.stopEditing();
                    store.insert(0, p);
                    grid.startEditing(0, 0);
    grid.getView().refresh();
  4. #4
    Please clarify can we mark the thread as closed?
  5. #5
    Yes, You can... Thanks,

Similar Threads

  1. [CLOSED] Adding a new grid record
    By adelaney in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Jun 06, 2012, 3:14 PM
  2. [CLOSED] [1.0] Store adding record
    By state in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Dec 11, 2009, 6:24 PM
  3. [CLOSED] Adding a new Store Record - Not a Record object
    By Steve in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 15, 2009, 7:40 AM
  4. Adding one record in a grid
    By nuno_Santos in forum 1.x Help
    Replies: 1
    Last Post: Apr 14, 2009, 5:55 PM
  5. Adding Form fields at run time
    By sz_146 in forum 1.x Help
    Replies: 1
    Last Post: Feb 10, 2009, 6:18 PM

Posting Permissions