I want to use model values on view page but in shortcode way?
For Example:
#model.name prints name which is assigned to model by controller.
But I want to use it with out #model.name by another token or shortcode?
For example now we use #model.Name for print its value on view page but I want that value with out using #model.Name.
I want to use another token which can print the same value of it.
I have found a solution; I can use tuple with view bag.
A view bag is a dynamic object using session, so make a tuple and then pass it to view.
Related
How can i create a form like the one on linkedin. On form input type when i type is going to fect data from a database if not existis is going to create it and fetch d and store to another table
on form input type, immediately get result: This can be done by AJAX. Laravel support Vue which can do this easily:
1a. call a function in the mounted() part.
1b. the function call itself by putting setTimeout(this.functionName,1000) at the end.
1c. in the function, check if the text in the text box is changed. if yes, make a request by axios.get('blablabla').then(response=>{//put the response into vue dataArrayName in data part});
1d. the html template is auto-updated by v-for="dataArrayName"
looks like the search is done by comparing char by char from the beginning of the string to the data.
if you press enter, pass the search string to the controller, use some logic to determine whether it is needed to create row in database
I have a table that has attributes not common to all rows that will be inserted, which mean my schematic will allow some columns to be empty and this will depend on the type selected.
The tables
Item table
ItemId
Name
Location
Typeid
Type table
Typeid
Desc
Upon a certain type selected (from a dropdown) in the form, some attributes in the item would be shown to the user and they would be have to be entered. How do I approach this.
You'll likely have a controller action (probably a controller) per table so you get separate urls for SEO. You'll also want a view per table as well as these values aren't really shared. You could create an ivory castle that would render a table given a generic List or DataTable, but if you're leaning that route, just use a control for it.
You can also do it with Javascript and AJAX. You can have a div which is hidden called 'item-form'. And on selecting one of the dropdown options, a javascript function can fill the item-form with the html for the selected item type (with the necessary attributes) and make the div visible.
Something like -
$("#dropdown").change(function(){
if($(this).val()==1)
$("#item-form").html(); //form with the attributes for type 1
else if ($(this).val()==2)
$("#item-form").hmtl(); //form with the attributes for type 2
});
You could fill the div's using calls to controller actions that are specific to the type selected which would return partial views.
I have a grid called myGrid. The column A of myGrid is a lookup that shows 2 values: the code, and the description.
I would like to copy the selected item's description into a second column of myGrid.
What would be the best way to do this?
I have encountered this sometimes ago and the solution I found is a bit complicated but works fine.
I had to create a form from scratch which is currently used in the lookup.
When calling the form in the lookup() method, don't forget to put "element" in the arguments.
In the init method of the new form, use element.selectMode(YourTable.Code) to specify which field will be selected. Override the closeSelect() method of the new form and make it call a parm method located in the caller form. This parm method will set the YourTable.Description field of the current record. Send the Description related to the record from YourTable selected by the user in the lookup.
The new form should be a window of type Popup, with the toolbar hidden and always on top. Its datasource should be YourTable.
Call the new form from the lookup method (or better, from a method at the table level called from the lookup method) using ClassFactory.formRunClass(args).
I found a 'simple' solution: i've to simply override the method modifieldfield
I have made the MVC Music Store through the tutorials and I'm now currently changing and adding things to the site to my liking. What I'd like to be able to do is open the Artist page and have the letters A-Z and All written across the screen in a bar at the top to allow users to browse Artists by the first letter of the bands name. What method would I use for this? Would a parameter help me?
You can use a parameter to filter data. When you populated model in controller action use default filter parameter as either 'All' or 'A' (first letter). Then filter model data and then return it with view. For 'All' obviously skip filtering logic.
On view you can have ActionLink for every letter linked to same action and passing letter as parameter. This way you can use same action to display data and all you will need action links passing parameter to that action and displaying data will be same (either use webgrid or any other way to display data).
I was wondering if there was a way to bind the value of an input field straight to the property in the Model through a strongly typed model. For example, let's say my Model is an Address object. I want to be able to say Html.Textbox(Model.Address1.State, "state", Model.Address1.State). So the first parameter would be the explicit property I want to bind to of the model with the value from the user, the second parameter would just be the DOM id, and the third value would be the initial value to input when I render the view.
I know you can do Html.TextBox("Address.State") and have a custom binder which would create the Address object for you and populate the state property. I need Html.Textbox(Model.Address1.State).
Help?
I think the FluentHtml stuff from the mvccontrib code is what you may want to check out.