-
3 Apr 2012 4:36 AM #1
Answered: mark invalid for grid apnel.
Answered: mark invalid for grid apnel.
Hi Guys,
I have a grid panel and want to mark it as invalid if there is less then 0 record.
I need some thing like the form.fields markInvalid() method which will make the border appear red. So i want to make the grid panel border to become red.
How can i achieve the same for a grid panel. ??
Thanks
Punith
-
Best Answer Posted by scottmartin
You do something like this:
Code:// test button to mark the grid as error text: 'red alert!', handler: function() { grid.body.applyStyles({ 'border-color': '#ff0000' }); }You will need to make adjustments as needed.Code:// add listener to grid to display a tooltip if there are no records listeners: { afterrender: function(grid) { if (grid.store.totalCount === 0) { var view = grid.getView(); view.tip = Ext.create('Ext.tip.ToolTip', { // The overall target element. target: view.el, // Each grid row causes its own seperate show and hide. delegate: view.itemSelector, // Moving within the row should not hide the tip. trackMouse: true, // Render immediately so that tip.body can be referenced prior to the first show. renderTo: Ext.getBody(), listeners: { // Change content dynamically depending on which element triggered the show. beforeshow: function updateTipBody(tip) { tip.update('There are no records in your grid, go find some!'); } } }); } } }
Regards,
Scott.
-
3 Apr 2012 9:30 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
Have a look at:
.x-panel .x-grid-body {
border-color
}
Regards,
Scott.
-
4 Apr 2012 1:53 AM #3
HI scott thanks,
But how can i add a error message for this, as it works for markinvalid() ??
as the user hovers on the grid component i want to show the error message
-
6 Apr 2012 2:26 PM #4Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
You do something like this:
Code:// test button to mark the grid as error text: 'red alert!', handler: function() { grid.body.applyStyles({ 'border-color': '#ff0000' }); }You will need to make adjustments as needed.Code:// add listener to grid to display a tooltip if there are no records listeners: { afterrender: function(grid) { if (grid.store.totalCount === 0) { var view = grid.getView(); view.tip = Ext.create('Ext.tip.ToolTip', { // The overall target element. target: view.el, // Each grid row causes its own seperate show and hide. delegate: view.itemSelector, // Moving within the row should not hide the tip. trackMouse: true, // Render immediately so that tip.body can be referenced prior to the first show. renderTo: Ext.getBody(), listeners: { // Change content dynamically depending on which element triggered the show. beforeshow: function updateTipBody(tip) { tip.update('There are no records in your grid, go find some!'); } } }); } } }
Regards,
Scott.


Reply With Quote