[CLOSED] GridPanel : Grid with AutoSave Date not insert in grid

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] GridPanel : Grid with AutoSave Date not insert in grid

    I do bellow code but the date not show in grid after click add

    <script>
        var addRecordtoGridPFNomination = function (form, grid) {
            if (!form.getForm().isValid()) {
    
                return false;
            }
            console.log(form.getForm().getValues());
            grid.store.insert(0, new Model_PFNomination(form.getForm().getValues()));
            form.getForm().reset();
        };
    
    
    </script>
    @( X.FormPanel()
        .Border(true)
        .Title("Nominee")
        .BodyStyle("background-color: #F1F1F1;")
           .Items(
                  X.FieldSet()
                  .Border(false)
                  .ColumnWidth(0.4)
                  .Items(
                        X.FieldContainer().Layout(LayoutType.HBox)
                         .Items
                            (
                                X.DateField()
                                .ID("NomineeDateofBirth")
                                .Name("NomineeDateofBirth")
                                .FieldLabel("Date of Birth")
                                .AnchorHorizontal("100%")
                                .Format("dd-MM-yyyy")
                               .LabelAlign(LabelAlign.Right)
                             )
                                 ,
                                 X.GridPanel()
                                .ID("GridPFNomination")
                                .Scroll(ScrollMode.Both)
                                .ColumnWidth(1.0)
                                .AutoScroll(true)
                                .Height(150)
                                .SetAutoScroll(true)
                                 .Store
                                         (
                                            X.Store()
                                            .ID("Store_PFNomination")
                                            .Model
                                                (
                                                        X.Model()
                                                        .Name("Model_PFNomination")
                                                        .IDProperty("EmployeeNomineeID")
                                                        .Fields
                                                            (
                                                                X.ModelField()
                                                                .Name("NomineeDateofBirth")
                                                                .ServerMapping("NomineeDateofBirth")
                                                                  .Type(ModelFieldType.Date)
                                                                  .DateFormat("dd-MM-yyyy")
                                                             )
                                                 )
                                                   
    
                                            )
                                                  .ColumnModel
                                                (
    
                                                              
                                                       X.DateColumn()
                                                        .DataIndex("NomineeDateofBirth")
                                                        .Text("Date of Birth")
                                                        .Sortable(false)
                                                        .MenuDisabled(true)
                                                         .Resizable(false)
                                                        .Width(100)
                                                        .Format("dd-MM-yyyy")
                                                        
                                            )
                                                    .Listeners(l => l.SelectionChange.Handler = @"if (selected[0])
                                                                                                {
                                                                                                    this.up('form').getForm().loadRecord(selected[0]);
                                                                                                }"
                                                                )
    
                                                )
    
                                            )
                                         .Buttons(
    
                                                    Html.X().Button()
                                                        .Text("Add")
                                                        .Icon(Icon.UserAdd)
                                                                    .Handler(@"addRecordtoGridPFNomination(this.up('form'), App.GridPFNomination)"),
    
                                                    Html.X().Button()
                                                   .Text("Reset")
                                                    .Handler("this.up('form').getForm().reset();")
                                                )
    
                     )
    Last edited by Daniil; May 26, 2015 at 4:19 PM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    I just tried your code and it appears working to me.

    I do:

    1. Pick some date in the DateField
    2. Click the Add button
    3. The new row appears with the picked up date shown
  3. #3
    Hi
    I try again steps you follow , but not working .I use
    FF 35.0.1 and 38.0.1
    Chrome 42.0.2311.152 m

    may be this will help you for suggest any thing. I try

    console.log(form.getForm().getValues());
    Click image for larger version. 

Name:	Untitled.png 
Views:	31 
Size:	9.9 KB 
ID:	23984

    Date format of date field and date format of the object in firebug console are different.so is that a problem?

    After click on add a blank row is insert in grid

    Click image for larger version. 

Name:	Untitled.png 
Views:	19 
Size:	2.8 KB 
ID:	23986
    Last edited by matrixwebtech; May 21, 2015 at 4:46 AM.
  4. #4
    any thought ? what's going wrong in my case?I stuck in middle of development of a very vital screen.
  5. #5
    I am give some more images of my local machine date formats may be this is help you for better understanding
    Click image for larger version. 

Name:	tz.png 
Views:	27 
Size:	27.6 KB 
ID:	23992
    Click image for larger version. 

Name:	cf.png 
Views:	29 
Size:	48.2 KB 
ID:	23993
    Click image for larger version. 

Name:	rl.png 
Views:	37 
Size:	48.0 KB 
ID:	23994
  6. #6
    Hi
    I change the javascript function and format the date as d-m-Y and insert in model manually and its working , but my question is why previous code not working for me?

    var addRecordtoGridPFNomination = function (form, grid) {
            if (!form.getForm().isValid()) {
    
                return false;
            }
            var d = form.getForm().getValues().NomineeDateofBirth
           
            console.log(d)
            d=Ext.Date.format(new Date(d),'d-m-Y')
            console.log(d)
           // grid.store.insert(0, new Model_PFNomination(form.getForm().getValues()));
            grid.store.insert(0, new Model_PFNomination({ NomineeDateofBirth: d }));
            form.getForm().reset();
        };
  7. #7
    Please try to add this to your initial code that is not working.
    .SubmitFormat("dd-MM-yyyy")
  8. #8
    thanks a lot,
    .SubmitFormat("dd-MM-yyyy")
    is working also. so previous submitted date format different because of my local machine's date format?
    Last edited by matrixwebtech; May 22, 2015 at 6:06 PM.
  9. #9
    so previous submitted date format different because of my local machine's date format?
    Yes, OS's locale settings might affect a default value of a DateField's SubmitFormat.
  10. #10
    again I faced a problem I load the grid with proxy which return "NomineeDateofBirth":"2015-05-22T00:00:00" which is not displayed in grid

    I set datecolumn
       X.DateColumn()
     .DataIndex("NomineeDateofBirth")
    .Text("Date of Birth")
    .Sortable(false)
    .MenuDisabled(true)
    .Resizable(false)
    .Width(100)
    .Format("dd-MM-yyyy")
    Model as

    X.ModelField()
    .Name("NomineeDateofBirth")
    .ServerMapping("NomineeDateofBirth")
    .Type(ModelFieldType.Date)
    .DateFormat("dd-MM-yyyy")
    I try http://forums.ext.net/showthread.php...l=1#post123756 ,and when grid load via proxy the date show but when I try to add a date on click Add not working .
    Last edited by matrixwebtech; May 23, 2015 at 3:35 AM.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Grid with AutoSave (row update only)
    By glenh in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 16, 2014, 1:51 AM
  2. [CLOSED] Grid with AutoSave with Combobox
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 08, 2014, 11:57 AM
  3. Grid with AutoSave sample
    By PetrSnobelt in forum 1.x Help
    Replies: 3
    Last Post: Apr 27, 2011, 11:33 AM
  4. Replies: 4
    Last Post: Feb 02, 2011, 8:23 PM
  5. Grid Insert
    By kumarxlnt in forum 1.x Help
    Replies: 8
    Last Post: Sep 17, 2009, 7:29 AM

Posting Permissions