PDA

View Full Version : mark invalid for grid apnel.



punith.mailme
3 Apr 2012, 4:36 AM
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

scottmartin
3 Apr 2012, 9:30 AM
Have a look at:

.x-panel .x-grid-body {
border-color
}

Regards,
Scott.

punith.mailme
4 Apr 2012, 1:53 AM
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

scottmartin
6 Apr 2012, 2:26 PM
You do something like this:



// test button to mark the grid as error
text: 'red alert!',
handler: function() {
grid.body.applyStyles({
'border-color': '#ff0000'
});
}




// 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!');
}
}
});
}
}
}


You will need to make adjustments as needed.

Regards,
Scott.