How to get itemid text using itemid value in treecntrl? - tk-toolkit

I'm using treectrl in my GUI application.
use the below to get the active id of the item
set id_no [$tree2 item id active ]
puts "id_no $id_no"
how to get the text associated with the item id?
thanks
Nagaraj

Related

Checkbox reveal which items are selected on page

on my page a user can select multiple items.
I use a checkbox and iterate over all the items of a user.
Now I want to show the user the total price of all the items he selected on that page.
So to say the total price of the shopping cart.
How can I access the ids of my items on the same page that the user clicks on them? I know that in the controller I can access them by
Item.find(params[:items])
Thanks a lot in advance :)
You'll need to do this via Javascript.
One way is to store the id in the data tags of your html element (checkbox in this case)
Then you can get this value in your Javascript callback as
element.getAttribute('data-type');
or if you are using jQuery
$(this).data("id")
Now you will need to access the value of the item (individual price for the item with the selected id) as well in Javascript. You can do this by either storing the mapping of id to price in a js variable
let prices = <%= #items.select(:id, :price).to_json %>;
or alternatively, you can just store the price in a data-attribute of each checkbox, and use this value to update the total selected price.

SelectList method MVC

Problem Description:
I am using ASP.NET MVC and I have the following method in my Controller Class. This method uses SelectList method to select a list of items from the database. These items will then be passed to the view to be displayed in a drop down list.
public ActionResult Edit(int id)
{
Album album = db.Albums.Find(id);
ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId);
return View(album);
}
My Understanding of the selectMethod:
I know that the first param takes a list of items.
The third param is the property to be displayed.In this case, we will be displaying the name property of the Artists.
Based on my research, I found out that the 4th param is the default value that will be displayed on the dropdown list.
My Question:
1) I would like someone to help me understand about the second param.
2)Since we are displaying names of the artists, how can we display a default artist name in the fourth param using Artist ID?
I hope you guys understood my questions. I would be happy to clarify them to you if you need me to do so.
The second parameter is the name of the "value" property or field on each element in the first parameter. Since two artists could conceivably have the same, it's generally better to use an ID column (as in the example) so that you know specifically which item was selected.
In the example, you are providing the artist of the currently-viewed album as the default to appear. Assuming that db.Artists includes an artist whose ArtistId property matches the given value, the rendered HTML will produce a select list where that artist is selected.
Did that answer your questions?
Per the documentation:
The first parameter is an IEnumerable of objects from which to construct the list.
The second parameter is the name of the object property (for each object in the list) to be used as the value attribute of each rendered HTML <option> element.
The third parameter is the name of the object property (for each object in the list) to be used as the text attribute of each rendered HTML <option>.
The fourth parameter is the default selected value (which indicates the element of the list that will be rendered with the selected attribute).

How to get the selected text from a system.web.mvc.selectlist

I have a system.web.mvc.selectlist when I use .selectedvalue it gives me the value as expected however I use an int ID as the value and would like to get the display text instead.
Update
I've created a selectlist and I'd like to retrieve the selected text on the next line of code. I.e.
SelectList sl = new SelectList(items, "id", "name", 10);
String txt= sl.selectedvalue.text;
That last line is where I am stuck. I'm looking to get the name field for the item with id 10. Ideally without looking up in the db as I want a generic function I can use on all select lists.
I don't think this is possible since the text isn't passed back to the server in a post, only the value is. I can think of two ways to get it though:
Query the database with the value to get the text.
Set the text in a hidden field on the client side before posting the
form. You can do this with jQuery for example.

sending email list item when ever a new item is created in sharepoint 2007

I am not able to send email from Custom list with item data when ever a new item is added & updated in custom list in sharepoint 2007.
Eg: I have a list with 3 fields as NAME, PLACE,STATUS. when we creaste new item & Particular person can edit that item then i need email alert with 3 fields data which i entered.

ListBox gets wrong selected value, how can i get the correct value?

I have a listbox that has the following items and values right now.
Items, Misc. Charge/Taxes/Labor Charges
Value, 50.00/50.00/100.00
The problem is when i select the taxes item, it will turn it into Misc. Charges because they have the same value. Is it possible to have the listbox get the correct item and value if the values are the same??
Thank you!
Use the value attribute as the unique id (miscCharge, Taxes) and the text attribute as what is displayed to the user (50.00, 50.00).
<asp:ListItem value="item1" Text="50" Selected="True"></asp:ListItem>
<asp:ListItem value="item2" Text="50"></asp:ListItem>
ListItem selectedItem = list1.SelectedItem;
string id = list1.SelectedItem.Value;
string text = list1.SelectedItem.Text;

Resources