I have multiple buttons with similar names. Major similarity is the suffix _min.
How can these all be disabled based upon the part of the name (and thus not based upon whole name?
btnX_min.IsEnabled = false;
btnY_min.IsEnabled = false;
btnZ_min.IsEnabled = false;
Needs to become:
for all buttons with string _min in Name, IsEnabled = false
How to accomplish?
Depending on where all these buttons are located in your Visual tree you might want to use the VisualTreeHelper class to be able to find all of them. Please refer to the recursive FindVisualChildren method here:
Find all controls in WPF Window by type
...and try this:
foreach (Button button in FindVisualChildren<Button>(this).Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains("_btn")))
button.IsEnabled = false;
I didnt check but try this:
IEnumerable<Button> buttons = mainGrid.Children.OfType<Button>(); //GridMain is the main Layout
foreach (Button btn in buttons)
{
if (btn.Name.Contains("_min"))
{
btn.IsEnabled = false;
}
}
Related
My Problem:
This is my form
I would like to just filter out same ID rows
Barely any code to show pretty much dragged and dropped entity-es and did some customizing.
Toolstrip and datagrid are binded to same source
My Goal:
I would like my form to filter out only the rows with same ID as ID in textbox when I navigate with toolbox buttons
My thoughts so far: Perhaps I can make a query where ID in textbox matches ID in first column and weed out those rows and just display them. But how would that keep the format I have? Comboboxes etc.. some columns have different binding sources, for example column #2, column#3 are have different binding sources as opposed to column#1(to which i'm trying to filter rows) and column#4,5
Edit: I have tried following
nastavniPlanProgramDataGridView.CurrentCell = null;
foreach (DataGridViewRow row in nastavniPlanProgramDataGridView.Rows)
{
if(row.Index!=rowIndex)
{
row.Selected = false;
row.Visible = false;
}
else
{
if(row.Index==rowIndex)
{
row.Selected = true;
row.Visible = true;
}
}
However i keep encountering an error when executing row.Visible=false;
Solved by simply adding the following before executing the above code-snippet in the question.
AllowUserToAddRows = false;
I have a bunch of panels out of which one does not have a form. While navigating between the panels I need to check if the form.isDirty(). Obviously it works fine as long as I don't hit the panel with no form on. Its a card layout and I am currently using:
Ext.getCmp('content-panel').getForm().isDirty()
I need to check before executing this line if the panel actually has a form. Is it possible to do this in ExtJS 4?
This code is working for requirement,we can access the 'form' property of the panel.If the panel contains the form then this Property return the form object in return and if the panel doesn't contains the form it return the 'undefined' which satisfied your requirement.
var formFlag = Ext.getCmp('content-panel').form;
if(formFlag === undefined){
console.log('form is absent');
}else{
console.log('form is present');//formFlag is the form object in this case
}
The component query should help you to check if there is a form inside the panel and you have to check if the panel is a form
var panel = Ext.getCmp('content-panel');
//Check if this is a form
var isForm = panel.form
//Check if an inner panel is a form
var hasForm = panel.query('form');
if(isForm && hasForm.length > 0){
//Is or has a form
}
Found a workaround. Posting just in case if anyone else might be looking for same thing.
I split my statement in following
var formCmp = Ext.getCmp('content-panel'); and then
called formCmp.getForm
Note: getForm and getForm() return different values.
I'm working with an ExtJS 4 propertygrid that can list three different kinds of items that display when clicked on in another grid. One kind of item has to have a particular field hidden, so that it is't shown but any updates caused by editing other fields aren't affected by potentially missing information.
Attempts of using hidden/isHidden/visible/isVisible, with quoted and unquoted true/false values, haven't worked, and show the ShapeLength field in the propertyGrid.
Is there a "hidden: true" setting within the sourceConfig that I can apply somehow?
Example code:
var lengthDisplayName = '';
if(record.data.Type_ID == 'Circle(s)'){
lengthDisplayName = 'Radius (mm)';
}
if(record.data.Type_ID == 'Triangle(s)'){
lengthDisplayName = 'Side Length (mm)';
}
detailsGrid.sourceConfig['ShapeLength'] = {displayName: lengthDisplayName, type: 'number'};
if(record.data.Item_No == '-1'){
detailsGrid.sourceConfig['ShapeLength'] = {
displayName: lengthDisplayName,
type: 'number'
//, hidden/isVisible/visible value set here
}
};
No there is no hidden property for sourceConfig. But one possibility is to remove the property from the sourceConfig and reinsert it if it should be visible again.
delete detailsGrid.sourceConfig['ShapeLength'];
Was directed to an answer by a colleague - I can getRowClass within the propertyGrid and apply a hidden style on source data for an identifying property and the row name to hide, or else return out:
detailsGrid.getView().getRowClass = function(row) {
if(detailsGrid.source['Item_No'] == '-1' && row.data.name == 'ShapeLength')
return 'x-hidden';
return;
};
i am working in extjs4. i have grid with checkbox selection model. Grid is displaying files and folders. If folder get selected then i want to hide some menu. So have written code as-
selectionchange:function( model, selected, eOpts ){
var centralPanel = me.up();
var actionBtn = centralPanel.queryById('libraryactionBtn');
if(selected.length > 1) {
actionBtn.show();
//var i=0;
for(i=0;i<selected.length;i++)
{
if(selected[i].data.isLeaf)
{
centralPanel.queryById('library-action-menu-view').hide();
centralPanel.queryById('library-action-menu-viewOrAddTag').hide();
centralPanel.queryById('library-action-menu-viewOrAddNotes').hide();
centralPanel.queryById('library-action-menu-copyToCompaign').hide();
centralPanel.queryById('library-action-menu-copyToProject').hide();
centralPanel.queryById('library-action-menu-sendLink').hide();
centralPanel.queryById('library-action-menu-addtofavorite').hide();
centralPanel.queryById('library-action-menu-downloadItem').hide();
}
}
} else {
actionBtn.hide();
}
where selected.data.isLeaf is false for folder. Its executing correctly only first time. Next time when i am selecting file,then also its hiding menu for file. And if folder is deselected then also its hiding menu. So what modifications i need to do
first of all I don't see any code that shows the menu..You are just hiding the menu.
Secondly make sure selected[i].data.isLeaf is false and not "false".
I am trying to disable couple of fields and make them readonly via hook_page_alter(). I was able to do check if user is viewing the page edit section (the form edit)
$page['content']['system_main']['#node_edit_form'] == TRUE)
then when I tried to disable couple of fields, I found that select list can be disabled by this code:
$page['content']['system_main']['field_my_field_name_a_select_list']['und']['#attributes']['disabled'] = TRUE;
but if I use the following code it doesn't work:
$page['content']['system_main']['field_my_field_name_a_select_list']['und']['#disabled'] = TRUE;
I also found that I can not use the same code to disable a text area field:
$page['content']['system_main']['field_my_text_area']['und']['#attributes']['disabled'] = TRUE;
The above code doesn't disable the text area, but the same code can disable the select list!
Then I tried hook_form_alter() to do the same thing, and I was able to disable fields and when I checked the rendered array from $page array, I saw that it shows:
$page['content']['system_main']['field_my_field_name_a_select_list']['und']['#disabled'] = TRUE;
but when I set the same code in hook_page_alter(), it didn't work. Looks like something else will override it, I thought that hook_page_alter() is the last place to change markup.
Any idea what is the best way to disable/readonly any kind of field, inside hook_page_alter() in drupal 7?
Thank you
It works for text fields^
$form['field_secured_title']['und']['0']['value']['#attributes']['disabled'] = TRUE;
Like it said in the docs
You can use attributes :
$form['#attributes'] = array('disabled' => TRUE);