Return multi Columns

Dec 22, 2010 at 7:42 AM

Hi,

 

project awesome ... well is awesome

 

Is it possible to return the name and other columns when using the lookup list back to my controller. For example I would want to return the make, model and reg

 

Data.Add(new cars { Id = x, cMake = car.make, cModel = car.model, cReg = car.reg});


Ta

Dec 22, 2010 at 7:56 AM

Hi,

I didn't really understood what you meant, but, anyways...

the LookupController's LookupList action is called when the user searches in the lookup, you can set there in the ViewData["structure"] as many columns as need.

the lookup itself is used to search for an item and the value of the selected key(definded in ViewData["structure"]) is set in a hidden input, the value of that hidden input you get in your controller

Dec 22, 2010 at 9:11 AM

Let me try to explain a bit better.

 

Currently the Columns  Name and Key are returend to the popform when the user clicks on an Item from the lookup list. Is it possible to return other columns as well?

So for example a user would select a person from the look up list and the below funcation would return the Key (hidden input), Name (Shown), DOB(hidden input) back to the form.

        //this returns the string that is shown in the disabled textbox near the lookup button
        public ActionResult Get(int id)
        {

            return Content(id == 0 ? "" : Data.Where(o => o.Id == id).Single().Name);
        }
Dec 22, 2010 at 10:51 AM

You will get only the value of the hidden input, but you can get the name by having the Id on the server side

May 13, 2011 at 1:53 PM
o wrote:

You will get only the value of the hidden input, but you can get the name by having the Id on the server side

Hi o,

Could you please explain how can I get the name and other field's value on the server side after closing lookup list?

When user select a row and click OK, I need to fill some textboxes with selected row's values. 

May 13, 2011 at 2:02 PM

something like

<%=Html.Lookup("Fruit") %>

<script>

$('#Fruit').change(function(){

$.post('<%=Url.Action("theaction") %>', { par1: $('#Fruit').val() }, function(result)

{

//do something

}

)

});

</script>