i'm creating a x number of buttons runtime in this way:
btn is Control
btn <- ControlCreate(name,typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn..Caption = name
btn..Process[trtClick] = buttonAction
the buttonAction code is:
Info("You pressed: " + btn..Caption)
But the result of the buttonAction is always the last button name I create, for eg. I create a button named "Luca" and when I click it the result is: You pressed: Luca. Then i create a new button named "Antonio" but when I press "Luca" button the output is You pressed Antonio. How can I assign one button action runtime for every button?
Did you try to create a control per button ?
Where did you run the creation of the buttons ?
Like:
btn1 is Control
btn1 <- ControlCreate("test1",typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn1..Caption = "test1"
btn1..Process[trtClick] = buttonAction
btn2 is Control
btn2 <- ControlCreate("test2",typButton,mouseX,mouseY,mouseXRel-mouseX,mouseYRel-mouseY,True)
btn2..Caption = "test2"
btn2..Process[trtClick] = buttonAction
What result do you get ?
I don't have the last version of Windev for tests.
I'm afraid "btn" became shared to the windows when you use
<- ControlCreate
Related
So I have Rad Grid that contains data and I have in above the Add New Button. I want when user has permission to add to make it enable if he doses not have then its disable I search for hours for a solution and all I come is this code:
Dim cmditem As GridCommandItem = CType(gvDefCountry.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)
Dim ctrl As System.Web.UI.WebControls.Button = CType(cmditem.FindControl("AddNewRecordButton"), System.Web.UI.WebControls.Button)
ctrl.Enabled = False
But every time I run the code, I'm getting this error:
"Index was outside the bounds of the array"
The view looks like:
It should work. Where do you put the codes? if you put it in gvDefCountry_PreRender event of the grid, it will work just fine.
However, i would recommend you to hide the button altogether instead of disabling it, since there will be no visual difference between enabled and disabled state of the button, depending on the skin you use (In my case - Metro). Otherwise, you also need to change the styles to grey it out and remove the mouse hover effect.
try this
If (TypeOf e.Item Is GridEditableItem) AndAlso (e.Item.IsInEditMode) Then
For Each cmdItm As GridCommandItem In RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)
Dim Addbtn As LinkButton = CType(cmdItm.FindControl("InitInsertButton"), LinkButton)
Addbtn.Enabled = False
Dim btn As Button = CType(cmdItm.FindControl("AddNewRecordButton"), Button)
btn.Enabled = False
Next
End If
Iam using spark ui table and I have radio button group (Yes and No)and teaxtarea in each row.I have multipe rows.
My requirement is that if click on Yes ,then the textarea should be hidden only in that row.I wrote below code in load
var table = page.ui.get('/tablecv1/Table1');
var radiobtn = table.ui.getSibling('/tablecv1/Table1/Radio_Button_Group1');
radiobtn._instance.input.onchange = function(event){
if(radiobtn.getData() == "yes"){
radiobtn.ui.getSibling("Text_Area1").setVisible(true)
}
else{
radiobtn.ui.getSibling("Text_Area1").setVisible(false,true)
}
}
As of the now the code is working only for the first row.But for the secomnd row,on change of button it is not even going inside that function,the reason may be the control name is same for all.How can I handle this case where I should be able to click radio btn in any row and specific textarea should be hidden
You could pass the target radio button to the inline function. That would be like this:
this.setAreaVisibility = function(radiobtn) {
radiobtn._instance.input.onchange = function(event){
if(radiobtn.getData() == "yes"){
radiobtn.ui.getSibling("Text_Area1").setVisible(true)
}
else{
radiobtn.ui.getSibling("Text_Area1").setVisible(false,true)
}
}
}
Then on "On Change" event of the radio button element you should call this function like this:
me.ui.invoke("setAreaVisibility", me);
I have a modal popup that appears whenever an editor tries to save a component with some values (a date field in the past in this case).
In this popup I show the editor a few options (very similar to the default "Open Shared Item" dialog) and an OK/Cancel button combo. On Cancel I fire the "cancel" event and the editor goes back to the editing screen, all good here. On "OK" I want to change the value of the field to match whatever the editor selected, then save.
I tried to use an approach with FieldBuilder and the sample Boris mentioned on this other topic but I can't get to the field from my popup dialog.
Any suggestions on how I can go and modify the xml of the item (could be also a page) from a modal popup?
EDIT: Code used in getControlForFieldName
function getControlForFieldName(name) {
var fieldBuilder = $display.getView().properties.controls.fieldBuilder;
var fieldsContainer = fieldBuilder.properties.input;
var fieldsNode = fieldsContainer.getElement();
var fieldContainer = $dom.getFirstElementChild(fieldsNode);
while (fieldContainer) {
var labelNode = $dom.getFirstElementChild(fieldContainer);
var fieldNode = $dom.getNextElementSibling(labelNode);
var control = fieldNode.control;
if (control.getFieldName() == name) {
return control;
}
fieldContainer = $dom.getNextElementSibling(fieldContainer);
}
}
EDIT #2
After Frank's advice, and some help from Jaime & Frank offline, I got it to work as follows:
The popup is called from a Command Extension (Save & Close in my case)
The command.js specifies an event handler that gets called on "submit" (== OK was pressed)
$evt.addEventHandler(p.dialogPopup, "submit",
this.getDelegate(this._onPopupSubmit));
In my popup I am passing the selected item (it's a keyword ID) to the event handler:
this.fireEvent("submit", { id: select.options[select.selectedIndex].value });
and now back in the event handler _onPopupSubmit(e) I just read e.data.id, load this keyword, get properties like ID & Title, and update the metadata of the item using item.setMetadata("new metadata with updated values").
Simple :)
Your code runs in a popup, so any references you make to global variables will be taken from the popup window.
So when you get the fieldBuilder:
var fieldBuilder = $display.getView().properties.controls.fieldBuilder;
$display is a reference to a global variable. So this actually looks for the FieldBuilder in the popup window (which doesn't have one).
To get the FieldBuilder of the Component window, you can get it from the opener:
var fieldBuilder = opener.$display.getView().properties.controls.fieldBuilder;
You might want to consider actually passing the updated value to either a callback function or with a (custom) event though, since that makes your popup less dependent on opener. trick.
i have 2 aspax page.
client.aspx
popup.aspx
client.aspx contains a simple registration form. in this form i have to take one of the textbox value from popup.aspx. that textbox contains with a search button
when i click on search button popup.aspx page is opened in a popup window.
in popup.aspx i m showing a grid contains productCode and product name and a select button.
when i select a row of grid then corresponding product name should be displyed in textbox. and tht popup window should be closed.
Update
ImageButton imgbut = sender as ImageButton;
GridViewRow gvr = (GridViewRow)imgbut.NamingContainer;
lblKeyIndex.Text = grd_ProductMaster.DataKeys[gvr.RowIndex].Value.ToString();
lblProductName.Text = gvr.Cells[2].Text;
Session["ProdName"] = lblProductName.Text;
Server.Transfer("client_Master.aspx");
Response.Write("<Script>window.close()</Script>"); Response.Redirect("client_Master.aspx?ProdName=" + lblProductName.Text+"&ProdCode="+lblKeyIndex.Text)
on page load of client.aspx
if (Session["ProdName"] != null)
{
txtSelectProdName.Text = Session["ProdName"].ToString();
}
Open a pop-up window
In your pop-up window try to return the value to parent window.
I have added a button to a tab panel in the center region by calling
var add = tabSelection.addButton({
id : 'add',
text : 'Add',
hidden : true,
tooltip : 'Please highlight the correct value and click Add to create new contact',
handler : addContact
});
There are two radio buttons in the west region in an accordion layout, labeled 'internal' and 'external'. I want the tool tip to be changed dynamically by capturing the radio button click.
I am able to capture the radio button click and when I set the tooltip of the button accordingly,
add.setToolTip('Please highlight the correct value and click Add to create new internalcontact'); if internal client is clicked.
add.setToolTip('Please highlight the correct value and click Add to create new external contact'); when external is clicked.
You need to initialise tooltips for it to work:
Ext.QuickTips.init();
And use qtip instead of tooltip.
Also worked for me (on ExtJS 4.1):
Ext.getCmp('buttonId').setTooltip('Tooltip you want to insert');
Another solution without using id, for e.g. with a button tooltip:
var prev_button = new Ext.button.Button({
cls: 'prevButton',
listeners: {
mouseover: function(btn) {
btn.setTooltip('1 ' + granularity.getValue()
+ ' ' + _('before'));
}
}
});