ExtJs Gridpanel selection modal

2019-08-27 13:03发布

问题:

I have a two questions:

  1. How to set first row in ExtJs gridpanel as selected and
  2. How to write separate JS file for custom validations for phone nos and datefields and etc

Thanks in advance

回答1:

Assuming you have an instance of your grid, you can select the row using selectFirstRow(). Here is the sample code:

grid.getSelectionModel().selectFirstRow();

You can move your custom validations to another file. All you need to move your

Ext.apply(Ext.form.VTypes, {
    daterange : function(val, field) {
        var date = field.parseDate(val);
        ...
    }
});

to separate file. and ensure that the js file is included.



回答2:

try this to select first row in grid :

Ext.getCmp('grid').getSelectionModel().selectRow(0);


标签: Extjs