Sharepoint Toolpart Event Not Firing - sharepoint

I have created a Sharepoint WebPart, and I have given it a custom ToolPart that includes a Grid (a Telerik RadGrid, to be exact, though that is rather irrelevant). I have populated the grid, and created a GridButtonColumn object to add to the grid:
protected override void CreateChildControls()
{
GridButtonColumn c = new GridButtonColumn();
c.ConfirmText = "Really Delete?";
c.ConfirmDialogType = GridConfirmDialogType.RadWindow;
c.ConfirmTitle = "Delete";
c.ButtonType = GridButtonColumnType.LinkButton;
c.Text = "Delete";
c.UniqueName = "DeleteColumn";
grid.Columns.Add(c);
// ...
grid.DeleteCommand += new GridCommandEventHandler(Grid_DeleteCommand);
}
The grid renders correctly - populated with data and with the delete button present.
Now, when I click any of the delete button, the Grid_DeleteCommand() event does not get triggered. However, when I add a random button outside of the grid, it's click event gets triggered:
Button b = new Button();
b.Text = "Hello World";
b.Click += new EventHandler(Button_Click);
I'm not able to debug on this installation of Sharepoint (or maybe I can, but attaching to the process hasn't allowed me to do so yet), so the method of both of those events is simply a redirection to Google. That is how I check to see if the events fire:
string AbsoluteUri ="http://www.google.com";
Page.Response.Redirect(AbsoluteUri);
The only difference I can see between the two is that, with the 'Delete' button, it is nested inside of a Grid control, whereas with the 'Hello World' button, there is no nesting.
How would I be able to have the Grid_DeleteCommand fire when I click the button in the grid?

Using the Telerik Grid control, you should specify button's CommandName in your code.
Adding this line should solve the problem:
c.CommandName = "Delete";

Related

compute Visible property for a button, based upon length of a textarea field

I would like to calculate the visibility of a button based upon the content of a text area field (multi line edit box). it should contain at least some text.
I could use the onkeypress event (server) and perform a partial refresh on the button BUT I notice that the partial refresh spinner appears then when users are writing in the field. I would like to avoid this.
What options do I have?
You would be best off writing a client side script for that event. This script should show the button when there are more than 200 characters in the textarea. You will need to set the style visibility to hidden for the button initially. If the form can be edited multiple times, you will need to write this as a function and call it on page load as well as in the keypress event.
If you can use the keyup event instead of keypress, this may be better.
var textareaID = '#{id:textareaID}';
var buttonID = '#{id:buttonID}';
var textareaValue = document.getElementById(textareaID).value;
var visibility;
if (textareaValue.length > 200) {
visibility = 'visible';
}
else
{
visibility = 'hidden';
}
document.getElementById(buttonID).style.visibility=visibility;

Add tree component to OverFlowMenu

I am using codename one to create an application, and i am in front of a situation that is making me use the "tree component" in the pop-up of the OverFlowMenu
how can i do that?
That won't work. The overflow menu uses a renderer approach and isn't very customizable.
Instead add a command to the right side of the toolbar and show a popup dialog pointing at that button e.g.:
popupCommand = toolbar.addMaterialCommandToRightBar("", FontImage.MATERIAL_MORE_VERT, e -> showPopup());
private void showPopup() {
Button b = toolbar.findCommandComponent(popupCommand);
Dialog popup = new Dialog(new BorderLayout());
popup.add(BorderLayout.CENTER, new Tree());
popup.showPopup(b);
}

DialogTabPage object does not have method 'frameType'

This is related to my question posted here:
How to make dialog elments collapsible?
Another developer has added two groups to the dialog that is displayed when creating a payment proposal (CustVendPaymJournal_Vend Class) and the "Ok" and "Cancel" buttons are no longer displayed on smaller resolutions (1024x768).
To overcome this I am trying to group some dialog elements in DialogTabPage tabs. However I haven't had any success in my attempts.
This is what I have in the first couple lines of code in the dialog() method for CustVendCreatePaymJournal_Vend
public Object dialog()
{
LedgerJournalType ledgerJournalType;
DialogTabPage tab;
super();
tab = dialog.addTabPage("First tab");
}
I keep on receiving this error anywhere I try to add a tab in the dialog. I have tried to put it on CustVendPaymJournal (from which CustVendPaymJournal_Vend is inherited) also, but to no avail.
DialogTabPage object does not have method 'frameType'.
Try:
dialog = super();
tab = dialog.addTabPage("First tab");

C# TableLayoutPanel replace control?

I was wondering if it was possible to replace one control in a TableLayoutPanel with another at runtime. I have a combo box and a button which are dynamically added to the TableLayoutPanel at runtime, and when the user selects an item in the combo box and hits the button, I'd like to replace the combobox with a label containing the text of the selected combo box item.
Basically, if I could simply remove the control and insert another at it's index, that would work for me. However I don't see an option like "splice" or "insert" on the Controls collection of the TableLayoutPanel, and I was wondering if there was a simple way to insert a control at a specific index. Thanks in advance.
Fixed this by populating a panel with the two controls I wanted to swap and putting that into the TableLayoutPanel. Then I set their visibility according to which I wanted to see at what time.
This is what I've been able to come up with for what I needed. It gets the position of the ComboBox and makes a new label using the selected value.
// Replaces a drop down menu with a label of the same value
private void lockDropMenu(ComboBox dropControl)
{
TableLayoutPanelCellPosition pos = myTable.GetCellPosition(dropControl);
Label lblValue = new Label();
myTable.Controls.Remove(dropControl);
if (dropControl.SelectedItem != null)
{
lblValue.Text = dropControl.SelectedItem.ToString();
lblValue.Font = lblValue.Font = dropControl.Font;
// Just my preferred formatting
lblValue.AutoSize = true;
lblValue.Dock = System.Windows.Forms.DockStyle.Fill;
lblValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
myTable.Controls.Add(lblValue, pos.Column, pos.Row);
}
}

Problem in Handling the Mouse click of CListCtrl

I have a listctrl with CheckBox in it(LVS_EX_CHECKBOXES) .It is a single column List Control . My Problem is when I Click on the CheckBox the particular item is getting selected/UnSelected. But when I click on the Item text the corresponding Checkbox is not getting Selected/UnSelected . How to handle both the Scenarios.
To check the item when the user clicks on the item text, you'll have to handle the NM_CLICK message, which is sent whenever the user clicks on the item.
Something along the lines of:
CYourListCtrl::OnNMClick(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
int nItemIndex = pNMItemActivate->iItem;
BOOL bCurrentCheckState = GetCheck(nItemIndex);
SetCheck(nItemIndex, !bCurrentCheckState);
*pResult = 0;
}
I'm writing this without testing though, so you'll have to make sure that it doesn't conflict with the handler for clicks on the check box iteself.

Resources