I have a MVC3 view that has a Telerik grid with Person information. This grid will be "rebinded" when adding/changing/deleting a person via ajax.
On the same page is a user control with a partial view that contains 3 dropdown lists. How can I refresh the partial view and thereby the dropdownlists as a result from the rebind of the Telerik grid?
Many thanks, it looks to be going in the direction I want, but not the whole way. I tried to incorporate your tips, but didn't manage to get it work. Here are a little more details:This model contains, amongst others, a list of employees in a company and 2 lists of persons created on the bases of some condition based on the employees from the company.
Like this:
employee list = Person1, Person2, Person 3
Projectmanagers = Person1, Person2
Developers = Person1, Person3
The list with employees are shown in a Telerikgrid that can be used to Add, Update or Delete employees.
The sublists are displayed are displayed by meanse of a partial view and has 2 dropdownlists.
When I make a change to the one of the employees (via the Telerik grid) I want this change reflected in the dropdownlists. For instance, when I add a new employee
to the company, say Person4. I want this new employee to be available in the list with projectmanagers (when it fullfills the condion to be a project manager) or in the
developer list when it is a developer.
The Telerikgrid will be updated via Ajax.Now I also want to update the dropdownlists with Ajax after the Telerikgrid has been rebound (.ClientEvents(events => events.OnDataBound("Grid_onDataBound"))).
How to solve this??
You need to get the updated HTML for your partial view after the grid is bound. You can use the OnDataBound event of the grid and $.ajax to request an action method which will render the partial view. Here is a blog post showing how to do that.
Related
Eclipse RCP View Communication ,where one view contains nattable and another views contains jface controls like button, dropdown.
Currently for example there is 3 view/Editor as shown below
View1 - contains employee details which is a Nattable and
it's cell contains data like String, Long, boolean, date value.
each row represent one data,and other views are corresponding data of
selected row
View2 - shows Address which is corresponding to the selected row in the View 1,
User can modify data of view2.
View3 - shows department details of employe, which can also be modified
So all 3 views present data of one model say Employee
Employee
|_Name
|_EmpId
|_Married
|_DOJ
|_Address
|_Type
|_City Name
|_State
|_PinCode
|_Department Details
|_Department
|_Project
|_Manager
Problem:
I want to know what is best way of communcation between views1 and other view such that
On selection of row in view1 then other two view should be update correspondingly;
If any data changes in view2/view3 then view 1 should get notification for data change in other view
when condition 2 occurs then I want to show dirty row in view1.
The typical approach for inter view communication in an E4 application related to your described scenario is to use the ESelectionService to trigger handling of a selection for opening another view, and to communicate back via the Eclipse 4 event system.
For scenario one to open a view based on the selection in a NatTable you could use the E4SelectionListener in the NatTable Eclipse 4 Extension Feature. It is a ILayerListener that forwards the selection to the ESelectionService. An example can be found in the NatTable examples.
To inform view 1 about changes in another view, I would suggest to use the IEventBroker to send an event from view2/view3 and react on the event in view1. This way the views are decoupled as much as possible. Eclipse 4 event system is a good starting point for learning about the event system.
I have a model which contains a list of items.
The list will have no more than 100 items.
Hence, I grab this list in one hit when I grab the model.
I want to be able to create / edit this model in a view that has pageination on it.
If I have for instance 20 items in my list and a page size of 5 I see 4 pages. I find that when editting on any page other than 1 my models list comes though to the Action as null.
If I am on page 1, the models list only has 5 items.
I understand why this is, but I cannot figure out how to get round this without posting my model in chunks.
Is there a way I can do what I want, which is to post the model in 1 hit from a view that has pageination on it?
Not sure on the downvote - but I seem to have got there in the end.
I call this function to expand the table to show all rows before submitting.....
function expandTable() {
var oTable = $('#tblCategories').DataTable();
oTable.page.len(250).draw();
};
.....my model makes it through to the action intact with ALL of the list items present.
I have to make a form consisting of several sub forms which may or may not contain grids.
For simplicity lets say i am using 2 models
1. Applicant Detail : where the applicants basic information (Name, DOB, Gender) is placed.
2. Applicant Experience : where the applicants prev work experience details are being placed.
Now for organizing purpose i am thinking of making two different controllers Namely ApplicantDetail and ApplicantExperience and both will contain their respective functionalities. But as soon as the user enters his basic information i want the same view to call in the index view of ApplicantDetail which will have a grid and the user can enter his/her prev working details in the form of rows.
My basic question is, is there anyway that can i create single razor view which will contain the razor view of my ApplicantDetail as well??
I believe what you are looking for is RenderAction.
Using RenderAction you can invoke controller/view within any view.
So if you had some razor view and second Controller and View combination, you could invoke it like so within the first view:
#{ Html.RenderAction("Action", "Controller2"); }
This can be useful when trying to modularize functionality.
See this blog post from Phil Haack for more details:
Html.RenderAction and Html.Action
I am new to ASP.NET MVC and I have a question regarding viewing entity relationships.
Say I have an entity called 'Person'. This holds the usual data relating to a person (Name, Email, etc). I also have a 'Notes' entity. Under EF, a 'Person' can have many 'Notes'.
I have a Person controller where I can view and preform CRUD operations on a Person object.
I can show the notes in the view easily but what is the best way to allow a user to add/edit/delete these notes from the Person view? I am hoping to do this using AJAX and not have the user move to a completely different page to add/edit/delete a note.
Thanks in advance,
ViperMAN.
When they edit a note, popup a jQuery dialog pointing to your URL to edit or have a separate Ajax.BeginForm() on the page that the details go into. When they finish the edit call a method to refresh the notes.
So:
1. In your Notes grid (or whatever)
you have an edit link for each note called "edit"
this link looks something like the following:
This one actually uses 'notes' : )
http://www.iwantmymvc.com/dialog-form-with-jqueryui-and-mvc-3
ASP.NET MVC | Problem about showing modal dialog using jQuery dialog widget
ASP.NET MVC modal dialog/popup best practice
Also beware of this scenario for multiple links:
MVC3 - Only first row link works well with Jquery Modal Dialog
Now the urls you use to populate the dialogs would be for example
/Note/Edit/10
One thing to note - jQuery validation needs to know about these new items that are being loaded via ajax into the DOM , so in your partial view you need to tell jQuery validation to include the new items - I'll edit in a bit to add this, have to grab it from another machine.
I have one view page in MVC named as ‘Index’. There are 3 main controls in that view page. For better understanding, take below example as reference.
1. One Dropdown ‘Customer’
2. One Dropdown ‘Project’ (that depends on ‘Customer’)
3. List of Task (that depends on ‘Project’).
Currently first user needs to select ‘Customer’. So based on customer ‘Project’ dropdown data will be fetched from post method of Index and bind that ‘Project’ dropdown. After selecting ‘Project’, List of task will be fetch from post method of Index and bind those tasks. So every time page is loaded again.I want to do it by Ajax form submit.
My problem – those 3 controls are in one view page so I want to return page view using Ajax without using Partial View. Is this possible? If yes then how? Or any other solution so that I am able to display data without reload whole page again.
If u can give me example of such scenario then it will be good.