Populate different title on different fullcalendar view - view

I am using fullcalendar.io component to display data in calendar view. I have to use month/week/day view here. And I have to populate title on each even but that title would be different at different view. E.g. on month view title only my OrderId, but in week view title would be OrderId + location.
How can I populate different title on different view?

You can set the EventAfterRender
eventAfterRender : function(event, element, view) {
if (view.type == "month") {
element.attr('title' , 'Your custom title');
}
}

Related

Programatically add custom field to views not show up?

I'm adding a new fields to my views through my custom module.
When I open up the views page UI, the field is not show up. However, If I edit the view on UI and click add field, I can see my custom field is available to add.
My question, how can I add automatically that field to the list of fields to display on the views?
function mymodule_views_default_views() {
...
$handler->display->display_options['fields']['myfield']['id'] = 'fieldname';
$handler->display->display_options['fields']['myfield']['table'] = 'databaseTableName';
$handler->display->display_options['fields']['myfield']['field'] = 'fieldname';
...
}

detail row grid with popup editor

I read posts and seen examples but I am still strugling with setting up hierarchy grid with one popup editor form for both master/detail record(s).
I would like to setup a simple grid with html row detail
where grid data source is a nested json:
persons = [
{ name:"john", surname:"smith" },
{ name:"jane", surname:"doe",
contact: [
{ type:"email", value:"jane.doe#domain.com" },
{ type:"phone", value:"012345678" }
]
}
]
Top grid level displays name and surname where detail template shows
simple list of contacts (if any).
Grid needs to be editable through a popup editor where both data (master and detail) can be edited. Name and surname are binded to one form where contacts are displayed in a simple grid binded to a separate "contact" form located above it.
<form input fields for name and surname>
<form input fields for contacts, binded to a contacts table>
<contacts table>
<save><update><cancel>
Problems:
in detail row initialization I only get top level data (no contacts) so I am unable to render detail row with list of contacts
how to handle contacts part in popup editor? how to bind data?
Thank you for all your input, Peter
Found out that editing misbehaved due to missing "record id". Once I provided unique id I am getting expected results.
Duplicated question here.

What is the difference between view & partial view in mvc

i am learning mvc. so like to know what is the difference between view & partial view in mvc in terms of functionality.
normal view & partial view both render html in page....so what is the difference and limitation for two?
what are things are accomplish by partial view. please give me few scenario where people need to use partial view.
here is posting two code to load view based on dropdown value change.
$(function() {
$('#myddl').change(function() {
var url = $(this).data('url');
var value = $(this).val();
$('#result').load(url, { value: value })
});
});
public ActionResult Foo(string value)
{
SomeModel model = ...
return PartialView(model);
}
public ActionResult GetView(int id)
{
switch (id)
{
case 1:
return View("View1", model1);
break;
case 2:
return View("View2", model2);
break;
default:
return View("Default", modelDefault);
}
}
now see one action result return PartialView and another return just view to ajax method. which approach is right? when second approach need to use?
please guide me with knowledge. thanks
We use partial view to render a specific section of a page, like take an example of Customer. Your Index view of Customer controller will be a normal view while your grid of customers will be a partial view so that when you update or insert a new customer or delete a customer you will just render your partial view which contains grid of customers not the whole index view.
As far as i know, a partial is used as part of a view and can be shared across multiple views to provide extra functionality for those views. Also, views can be broken down to partials to make editing easier and eliminate redundancy. Hope it helps a little
Partial view kept to use as partial page of the main page(parent page).
What does mean of partial view? Actually in the main page we will have all the HTML page attributes as below:
html lang="en"
head
title
meta
body
But in partial view we will not have all above attributes.
Find the features of partial page:
1. Partial page will be light wait and get fitted into the any view.
2. This will use as the reusable component.
3. Partial view will be render inside of a View(parent view or page).
For all who coming from ASP.Net background they can understand partial view as user control.
Thanks
Afazal
mdafazal#gmail.com

how to export in excell sheet the entire view rather than only list in mvc3

In my below code I want to display all the data in excell sheet but not only a specific list ( i have comment it). My view content different list from different model and they are in a recursive way , there are partial view too. so i need to grap whole content of view ( whatever is seen on that view) and export it in excel . How can i do it?
public ActionResult ExportVchrReport(BillVoucher obj)
{
Response.AddHeader("Content-Type","application/vnd.ms-excel");
//var ls=(List<BillVoucher>)TempData["VchrRpt"];
//TempData["VchrRpt"]=ls;
//return View(ls);
var data = TempData["myModel"];
return View(data);
}

Populating a grid via autocomplete and posting the results

I have a view where I create a new company.
The company has a number of trades, or which 1 is a primary trade.
So when I enter the trades for that company, I select a trade via autocomplete, and this trade is added to a grid of trades underneath the autocomplete textbox. The grid contains the tradeId as a hidden field, the trade, and a radio button to indicate whether the trade is a primary trade and a remove button.
This is part of a form that contains other company details such as address.
Now I am wondering if I can use knockout and (maybe) jsrender to populate the grid without posting to the server?
When I have filled in the grid AND the other company details, I then want to submit the data to the controller post method.
Normally I use the Html helpers to post values to the controller, but I don't see how I can do that using knockout.
Yes you can use Knockout for this. If you have not checked the tutorials out yet then try this Knockout List and Collections tutorial. This should point you in the right direction. What you'll need to do is create a Trade object with observable properties and in a separate knockout view model create an observableArray to store trade objects. For information on posting to the server there are other tutorials in the same location.
function Trade(item) {
var self = this;
self.tradeId = ko.observable(item.tradeId);
self.tradeName = ko.observable(item.tradeName);
self.isPrimary = ko.observable(item.isPrimary);
}
function TradesViewModel() {
var self = this;
// Editable data
self.trades = ko.observableArray([]);
self.removeTrade = function(trade) { self.trades.remove(trades) }
self.save = function() {
$.post("/controller/action", self.trades);
}
}
ko.applyBindings(new TradesViewModel());

Resources