I have a webpart. I have a list of items (schools) that I must pick from. This list comes from another Sharepoint list. I made a tool part. This tool part creates a drop down list and populates it with the correct data. When I went to edit the web part properties, the drop down list is sitting outside of any other group. I want to add that drop down list into the "Miscellaneous" group. If I can't put it there, I want to create a custom group.
How do I do this?
To add other groups, you will need some client manipulations (jquery).
Or you can just create extra groups:
protected override void CreateChildControls() {
Panel panel = new Panel();
panel.CssClass = "ms-ToolPartSpacing";
Table table = new Table();
table.CellPadding = 0;
table.CellSpacing = 0;
table.Style["border-collapse"] = "collapse";
table.Attributes.Add("width", "100%");
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Controls.Add(new LiteralControl("<div class=\"UserSectionHead\"><b>Your Other Group:</b></div>"));
cell.Controls.Add(new LiteralControl("<div class=\"UserSectionBody\"><div class=\"UserControlGroup\">"));
Table innertable = new Table();
//build your innertable
cell.Controls.Add(innertable);
cell.Controls.Add(new LiteralControl("</div></div>"));
cell.Controls.Add(new LiteralControl("<div style='width:100%' class='UserDottedLine'></div>"));
row.Cells.Add(cell);
table.Rows.Add(row);
panel.Controls.Add(table);
this.Controls.Add(panel);
base.CreateChildControls();
}
Related
I want to hide certain elements in the view.
I managed to hid (with view..HideCategoryTemporary) all the elements I wanted except the marked one in the picture attached.
3D_House_before_hide
Element snoop
This element is a building section of category OST_Viewers.
Manually hiding the element category via the view works, but fetching all OST_Viewers in the code and hiding them does not work.
The following code contain the building section elements in addition to the grids,
FilteredElementCollector viewers_sections = new FilteredElementCollector(doc, v_id).OfCategory(BuiltInCategory.OST_Viewers);
FilteredElementCollector grids = new FilteredElementCollector(doc, v_id).OfCategory(BuiltInCategory.OST_Grids);
FilteredElementCollector elements_to_be_hidden = new FilteredElementCollector(doc, v_id);
elements_to_be_hidden.UnionWith(viewers_sections).UnionWith(grids)
foreach (Element e in elements_to_be_hidden)
{
cur_view.HideCategoryTemporary(e.Category.Id);
}
I've checked that viewers_sections contains the mentioned building sections however it is not hidden from the view.
After hide
How do I hide these building sections?
Please use View#SetCategoryHidden instead to turn off the visibility of the category, the result of the View#HideCategoryTemporary will be reset after closing the file. Here is the working example:
var gridCate = this.Document.Settings.Categories.get_Item(BuiltInCategory.OST_Grids);
var sectionsCate = this.Document.Settings.Categories.get_Item(BuiltInCategory.OST_Sections);
using(var trans = new Transaction(this.Document))
{
trans.Start("Hide Grids & Secions");
this.ActiveView.SetCategoryHidden(gridCate.Id, true);
this.ActiveView.SetCategoryHidden(sectionsCate.Id, true);
trans.Commit();
}
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";
I have been developing a component for Joomla 1.7.x, during development I need to add new component menu items to admin menu, it was easy by adding new rows to components table in DB in Joomla 1.5 times, but now it seems complicated to add a menu item by adding new row to menu table because of the database structure changes in Joomla 1.7
Is there a easy way to do this without reinstalling the component?
tHanks
The easiest way I found:
$table = JTable::getInstance('menu');
$data = array();
$data['menutype'] = 'main';
$data['client_id'] = 1;
$data['title'] = 'ITEM TITLE';
$data['alias'] = 'com-component-name';
$data['link'] = 'index.php?option=com_component_name&view=default';
$data['type'] = 'component';
$data['published'] = '0';
$data['parent_id'] = '117'; // ID, under which you want to add an item
$data['component_id'] = '10026'; // ID of the component
$data['img'] = 'components/com_component_name/assets/images/icon.png';
$data['home'] = 0;
if (
!$table->setLocation(117, 'last-child') // Parent ID, Position of an item
|| !$table->bind($data)
|| !$table->check()
|| !$table->store()
){
// Install failed, warn user and rollback changes
JError::raiseWarning(1, $table->getError());
return false;
}
To delete:
$table->delete(120); // item ID
$table->rebuild();
Based on http://docs.joomla.org/Using_nested_sets#Adding_a_new_node
Joomla 1.6+ menu items are stored under the #__menu table, with a special menu type called "main" for the admin menu.
Find your main component admin menu item's ID. You can add sub-items of that by declaring the parent_id column as the id of your main menu item, and setting the level column to 2.
The only other issue you are going to run into is the adoption of nested sets (lft and rgt columns). This is better way to handle parent-child relationships and the ordering of menu items. I'm unsure whether or not the parent_id or lft/rgt are used at this stage, but they are both filled in.
To add a new item, you would have to "shunt" all lft/rgt values by two for menu items with a value greater or equal to the position you wish to add your menu item. This should include the rgt of your parent item. If your parent item has no children, the lft for your new item will be the value of parent's left + 1. The value of the new item's rgt will be parent's lft + 2.
One thing to note with the lft and rgt is that the numbering applies to every menu item (front-end and back-end), so not doing it properly may have the potential to break your entire menu heirarchy. I think this is why the parent_id column is still used, and that there is an option in the admin area to "rebuild" the menu.
http://en.wikipedia.org/wiki/Nested_set_model
Here's a few SQL queries I came up with that did the trick (only the relevant parts shown):
SET #lastRgt := (SELECT rgt + 1 FROM #__menu WHERE alias="alias-of-preceding-menu-item");
UPDATE #__menu SET rgt=rgt+2 WHERE rgt > #lastRgt;
UPDATE #__menu SET lft=lft+2 WHERE lft > #lastRgt;
INSERT INTO #__menu (menutype, title, alias, path, link, type, published, parent_id, level, component_id, img, client_id, params, access, lft, rgt)
VALUES(..., #lastRgt+1, #lastRgt+2);
Worked for me on Joomla 2.5.
Admit's answer is in need of an update for Joomla 3.x
I'm sure it's correct for older Joomla versions which is why I'm not editing it.
This worked for me after further research and editing.
$table = JTableNested::getInstance('Menu');
$data = array();
$data['menutype'] = 'main';
$data['client_id'] = 1;
$data['title'] = 'ITEM TITLE';
$data['alias'] = 'com-component-name';
$data['link'] = 'index.php?option=com_component_name&view=default';
$data['type'] = 'component';
$data['published'] = '0';
$data['parent_id'] = '117'; // ID, under which you want to add an item
$data['component_id'] = '10026'; // ID of the component
$data['img'] = 'components/com_component_name/assets/images/icon.png';
$data['home'] = 0;
$table->setLocation(117, 'last-child') // Parent ID, Position of an item
if (!$table->bind($data) || !$table->check() || !$table->store()) {
// Install failed, warn user and rollback changes
JError::raiseWarning(1, $table->getError());
return false;
}
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);
}
}
I'm trying to programmatically put a LinearLayout inside of a ListView and am having some trouble. I want to do this so that I can insert horizontal columns inside each ListView cell. Here's the relevant snippet of code:
LinearLayout listArray[] = new LinearLayout[routeTable.GetTableHeight()];
for (int i = 0; i < routeTable.GetTableHeight(); i++) {
listArray[i] = new LinearLayout(this);
TextView view = new TextView(this);
view.setText(strList[i]);
listArray[i].addView(view);
}
// Create list
ListView list = new ListView(this);
list.setAdapter(new ArrayAdapter<LinearLayout>(this,
android.R.layout.simple_list_item_1, listArray));
layout.addView(list, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
This compiles, but the resulting list that is displayed does not display any of the strings in strList[]. Instead, the list elements that are displayed appear something like "android.widget.LinearLayout#47b63c0". Does anybody know how I could fix this so that the appropriate TextViews that are inside of listArray[] would be displayed?
ArrayAdapter just calls .toString() method on each object in the list and displays the resulting string in each list item. In your case, .toString() is called on LinearLayout, that is what you see as list element. It is also not clear what are the elements of routeTable.
You should subclass BaseAdapter so that you can construct necessary View for each list item yourself.