I want to add an image to a data grid column, I am using telerik grid for this, however I get the following error, its on Line 51:
Compiler Error Message: CS1525: Invalid expression term ')'
Source Error:
Line 49: column.Bound(o => o.HoursWorked).Title("Hours");
Line 50: column.Template(o =>
Line 51: {%>
Line 52: <img src="/Content/img/delete.png" alt="Delete" title="Delete"/>
Line 53: <%
Here is how I am trying to add an image to the column:
<div>
<%=Html.CustomGridFor("Hours", "WorkHours", "HoursWorked", GridOptions.EnableSelecting, Model).Columns(column =>
{
column.Bound(o => o.DateWorked).Title("Date").Width("65px");
column.Bound(o => o.Description).Title("Description").Width("120px");
column.Bound(o => o.HoursWorked).Title("Hours");
column.Template(o =>
{%>
<img src="/Content/img/delete.png" alt="Delete" title="Delete" onclick="javascript:deleteHours();" />
<%
}).Title("").ClientTemplate(
"<img src=\"/Content/img/delete.png\" alt=\"Delete\" title=\"Delete\"/>"
).Width(15);
}).HtmlAttributes(new { style = "width: 270px;" });
%>
</div>
Tried this too:
<div>
<%=Html.CustomGridFor("Hours", "WorkHours", "HoursWorked", GridOptions.EnableSelecting, Model).Columns(column =>
{
column.Bound(o => o.DateWorked).Title("Date").Width("65px");
column.Bound(o => o.Description).Title("Description").Width("120px");
column.Bound(o => o.HoursWorked).Title("Hours");
column.Template(o =>
{
%>
<img
alt="Delete"
src="/Content/img/delete.png"
/>
<%
});
</div>
Try to use this:
<div>
<%=Html.CustomGridFor("Hours", "WorkHours", "HoursWorked", GridOptions.EnableSelecting, Model).Columns(column =>
{
column.Bound(o => o.DateWorked).Title("Date").Width("65px");
column.Bound(o => o.Description).Title("Description").Width("120px");
column.Bound(o => o.HoursWorked).Title("Hours");
column.Template(o => string.Empty).Title("")
.ClientTemplate(
"<img src=\"/Content/img/delete.png\" alt=\"Delete\" title=\"Delete\"/>")
.Width(15);
}).HtmlAttributes(new { style = "width: 270px;" });
%>
</div>
Related
I have the following kendoUI grid:
<div class="row">
<div class="col-md-12">
<h4>List of SSF Pension Subscription</h4>
<p>
#(Html.Kendo().Grid(Model)
.Name("Grid")
.HtmlAttributes(new { style = "border: 0;" })
.Columns(columns =>
{
columns.Bound(s => s.PensionNumber);
columns.Bound(s => s.FirstName);
columns.Bound(s => s.FatherName);
columns.Bound(s => s.GrandName);
columns.Bound(s => s.FamilyName);
columns.Bound(s => s.BankLookup.BankName);
})
.Sortable()
.Navigatable()
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
.DataSource(dataSource => dataSource.Server()
.Model(model => model.Id(s => s.MemberID)))
)
</p>
#Html.ActionLink("Edit", "Edit", null, new { id = ???????}, new { #class = "btn btn-default" })
</div>
I want to get the selected row id after clicking on the edit button and pass that id to the action method.
Thanks in advance
I have a grid which loads data after search button is clicked. However i am running into the issue where when the user clicks on any of the column, it tends to call datasource read function.
Is there anyway to stop invoking read method when the column is clicked and only call the read function when search button is clicked?
Razor:
<div class="col-sm-6">
<div class="form-group">
#Html.LabelFor(model => model.EmployeeName, new { #class = "col-sm-4 control-label" })
<div class="col-sm-8">
#Html.TextBoxFor(model => model.EmployeeName, new { #class = "form-control"})
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="col-sm-6">
<div class="form-group">
<div class="col-sm-8 col-sm-offset-4">
<input id="btnSearch" type="submit" value="Search" class="btn" />
</div>
</div>
</div>
#(Html.Kendo().Grid<Portal.EmployeeViewModel>()
.Name("GridEmployeeInvitation")
.Columns(columns =>
{
columns.Bound(e => e.EmployeeNumber).Width("160px");
columns.Bound(e => e.EmployeeName).Width("180px");
})
.Excel(excel => excel
.FileName("File.xlsx")
.ProxyURL(Url.Action("Excel_Export_Save", "Shared"))
.AllPages(true)
)
.Pageable(x => x.PageSizes(new object[] { 10, 20, 50, 100, "All" }))
.Reorderable(reorder => reorder.Columns(true))
.AutoBind(false)
.Selectable()
.Sortable(sortable => sortable
.AllowUnsort(true)
.SortMode(GridSortMode.MultipleColumn))
.Scrollable(scr => scr.Height(322))
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains("Contains")
.StartsWith("Starts with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to"))))
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.ServerOperation(false)
.Read(read => read.Action("GetEmployees", "Admin").Data("GetSearchParameters"))
)
)
<script type="text/javascript">
$('#btnSearch').click(function (e) {
('#GridEmployeeInvitation').data('kendoGrid').dataSource.read();
});
function GetSearchParameters() {
return { employeeName: $("#EmployeeName").val()
};
}
</script>
I am working on rails 3 and using ajax to load a form, there is a country drop down that has values thats not loading properly. Its loading html entities of the "<" and ">" sign like "<" & ">".
This is how i am rendering the partial that has the countries list
$j('#insert_to').append("<%= escape_javascript(render :partial => 'verified_address', :locals => { :item => #item, :original_item => nil, :update_alert => false }).html_safe %>");
The output i am getting is
<span id=\"ship_to_country_container\">\n
<select id
=\"item_ship_to_country\" name=\"item[ship_to_country]\"><option value=\"\">-- Select --<\/option>\n
<option value="" disabled="disabled">-------------</option>\n<option
value="Afghanistan">Afghanistan</option>\n<option value="Aland Islands"
;>Aland Islands</option>\n<option value="Albania">Albania</option>\n<
;option value="Algeria">Algeria</option>\n<option value="American Samoa"
;>American Samoa</option>\n<option value="Andorra">Andorra</option>\n
<option value="Angola">Angola</option>\n<option value="Anguilla">
;Anguilla</option>\n<option value="Antarctica">Antarctica</option>\n<option
value="Antigua And Barbuda">Antigua And Barbuda</option>\n<option value="
;Argentina">Argentina</option>\n<option value="Armenia">Armenia</option
>\n<option value="Aruba">Aruba</option>\n<option value="Australia"
;>Australia</option>\n<option value="Austria">Austria</option>\n<option
value="Azerbaijan">Azerbaijan</option>\n<option value="Bahamas">Bahamas
</option>\n<option value="Bahrain">Bahrain</option>\n<option value="
;Bangladesh">Bangladesh</option>\n<option value="Barbados">Barbados<
;/option>\n<option value="Belarus">Belarus</option>\n<option value="
;Belgium">Belgium</option>\n<option value="Belize">Belize</option>
;\n<option value="Benin">Benin</option>\n<
html entities are getting rendered and not the actual tags
1st call: $j.ajax({
url: "/items/validate_address",
type: 'POST',
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $j('meta[name="csrf-token"]').attr('content'))},
data: data_address,
dataType: 'script'
});
this call the validate_address
<div id="verified_address" style="display:none">
<div id="verified_address_form" style="display:none;">
<%= form_for(item, :remote => true) do |f| %>
<%= render :partial => 'shipments/ship_to_address_form', :locals => {:f => f, :item => item}%>
<input type="hidden" name="update_alert" id="update_alert" value="<%= update_alert %>" />
<p><%= f.submit "Save", :style => 'width: 60px;' %> <%= link_to_function "Cancel", "$('verified_address_view','verified_address_form').invoke('toggle');$('order_address_id').style.position = '';$('order_address_id').style.zIndex = '';" %></p>
<% end %>
</div></div>
3rd Step: shipments/ship_to_address_form has the country dropdwon
<tr>
<td><label for="item_ship_to_country">Country</label></td>
<td>
<span id="ship_to_country_container">
<%= f.country_select :ship_to_country, {},{:selected => item.ship_to_country, :include_blank => '-- Select --'} %>
</span>
I figured out that the issue was the country_select call, i installed the gem country_select and the issue was resolved. Thanks for all your suggestions and help.
Here i m passing only single param from telerik to javascript function. i need to pass another param also
<a href="javascript:void(0);" onclick="AddOdometer(<%: b.VehicleRepositoryId %>)"
title="ADDTrip" id="A1">Add Distance</a>
whole code for reference
<% Html.Telerik().Grid(Model.VehicleList)
.Name("VehiclesRepositoryGrid")
.Columns(colums =>
{
colums.Bound(b => b.TruckNumber).Title("Vehicle Number")
.FooterTemplate(() =>
{%>
Total:
<%})
.Width(100);
colums.Bound(b => b.Month);
colums.Bound(b => b.FuelType).Title("Fuel Type");
colums.Bound(b => b.TotalDistance).Title("Distance")
.FooterTemplate(() =>
{%>
<%= Model.VehicleList.Sum(v=>v.TotalDistance)%>
<%})
.Width(100);
colums.Bound(b => b.TotalFuel).Title("Fuel")
.FooterTemplate(() =>
{%>
<%= Model.VehicleList.Sum(v => v.TotalFuel)%>
<%})
.Width(100);
colums.Bound(b => b.Mileage);
colums.Template(b =>
{
%>
<% if (b.TotalDistance == 0)
{%>
<a href="javascript:void(0);" onclick="AddOdometer(<%: b.VehicleRepositoryId %>)"
title="ADDTrip" id="A1">Add Distance</a>
<%}
else
{ %>
<a href="javascript:void(0);" onclick="EditOdometer(<%: b.VehicleRepositoryId %>)"
title="Edit">
<img src="<%= ResolveUrl("~/Content/Images/Edit.gif")%>" alt="Edit" title="Edit"
class="vaM" /></a> | <a href="javascript:void(0);" onclick="DeleteOdometer(<%: b.VehicleRepositoryId %>)"
id="DeleteVehicle">
<img src="<%= ResolveUrl("~/Content/Images/Delete.gif")%>" alt="Delete" title="Delete"
class="vaM" /></a>
<% } %>
<%
}).Title("Actions")
.Width(100).HtmlAttributes(new { #class = "taC" });
})
.Groupable(settings => settings.Groups(groups =>
{
groups.Add(o => o.TruckNumber);
if (ViewData["Grouping"] != null)
{
groups.Add(o => o.Month);
}
}))
.Scrollable(scrolling => scrolling.Enabled(false))
.Sortable(sorting => sorting.Enabled(true))
.Pageable(paging => paging.Enabled(true))
.Filterable(filtering => filtering.Enabled(true))
.Footer(true)
.Render();
%>
Not sure what your question is, is this what you want to achieve?
<a href="javascript:void(0);"
onclick="AddOdometer(<%: b.VehicleRepositoryId %>, <%: b.SecondParam %>)"
title="ADDTrip" id="A1">Add Distance</a>
I have a webpage with a partial view that has a button and displays some information. When the user clicks the button in this partial view, I need to be able to update that partial view from the controller within the action that gets called. Specifically, there is a string that I want to update. Here is my code so far, but it's not working..
partial view (_printLabel.rhtml)
<% if #printAsinEnabled %>
<%= check_box_tag(:needPrint, :needPrint, false,
:onchange => "if (this.checked) $('printLabelAction').show(); else $('printLabelAction').hide();") %>
<%=_('Need to print label?')%><br /><br />
<div id="printLabelAction" class="action" style="display:none;">
<% onPrintLabelClick = generateAjaxRequest(
{:controller => #controller.controller_name,
:action => 'processPrintLabelRequest',
:creturnWipItemId => creturnWipItemId,
:barcode => collectedItemData.fnsku,
:title => asinInfo["title"]},
["parameters: Form.serializeElements([$('printerAddress'),$('printerRemote_true'),$('printerRemote_false')])"]) %>
<%=_('Printing')%>: <%= collectedItemData.fnsku %> <br /> <br />
<%= radio_button_tag(:printerRemote, :false, !session[:printRemote]) %>
<label for="printerRemote_false"><%=_('Local Printer')%></label> <br />
<%= radio_button_tag(:printerRemote, :true, session[:printRemote]) %>
<label for="printerRemote_true"><%=_('Remote Printer')%> - <%=_('Printer Address')%>:</label>
<%= text_field_tag(:printerAddress, session[:printerAddress],
:onchange => onPrintLabelClick,
:onclick => "$('printerRemote_true').checked = true")%> <br />
<div style="text-align:right;">
<%= button_to_function(_("Print Label"), onPrintLabelClick) %>
</div>
<%=_('Error?')%>: <%= errorMessage %> <br /> <br />
</div>
Here is the div where it gets rendered originally:
<div id="Block_asinSummary" class="block">
...
...
<td height="200px" width ="70%">
<%= link_to asinInfo["title"], asinInfo["link"], :target => "_blank" %><br/><br/>
<% if !asinInfo["clothingSize"].nil? %>
<b><%= _('Size')%>: </b> <%= asinInfo["clothingSize"]%><br>
<% end %>
<font size='1'>
<% sku = collectedItemData.displaySku %>
<% if sku != collectedItemData.asin%>
<b>SKU:</b> <%= sku %><br>
<% else %>
<b>ASIN:</b> <%= collectedItemData.asin %>
<% end %>
<%= render(:partial => 'printLabel', :locals => { :creturnWipItemId => creturnWipItemId, :collectedItemData => collectedItemData, :asinInfo => asinInfo, :errorMessage => "HI" })%>
</font>
</td>
</tr>
</table>
...
...
<% end %>
And here is the controller code that is supposed to update "errorMessage" with a new string when clicked:
render(:partial => 'printLabel', :layout => false, :locals => { :creturnWipItemId => creturnWipItemId, :collectedItemData => #collectedItemData, :asinInfo => asinInfo, :errorMessage => "Bye" })
I am not seeing any errors from this, but the errorMessage string is not updating from "HI" to "Bye".
You can't call render partial from your controller. Instead, render the template and pass a different error message to the partial using an instance variable.