i have the following table component and i am using angulardart 0.11 and dart 1.4
#Component(
selector: 'table-component',
publishAs: 'ctrl',
template: '''<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th ng-repeat="col in ctrl.ItemsSource.ColumnDefs">{{col.displayName}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in ctrl.ItemsSource.Items">
<td ng-repeat="col in ctrl.ItemsSource.ColumnDefs">
{{item.properties[col.name].value}}
</td>
</tr>
</tbody>
</table>'''
)
class TableComponent {
Scope scope;
ItemsCollection ItemsSource;
TableComponent(this.scope) {
var columnDefs =[new ColumnDef(name:"id",displayName:"ID",isPrimaryKey:true),
new ColumnDef(name:"firstname",displayName:"First Name"),
new ColumnDef(name:"lastname",displayName:"Last Name"),
new ColumnDef(name:"language",displayName:"Language")];
var items = [new DynamicItem({'id':new DynamicProperty<int>('id',0),
'firstname':new DynamicProperty<String>('firstname','Some'),
'lastname':new DynamicProperty<String>('lastname','One'),
'language':new DynamicProperty<String>('language','English')}),
new DynamicItem({'id':new DynamicProperty<int>('id',1),
'firstname':new DynamicProperty<String>('firstname','Another'),
'lastname':new DynamicProperty<String>('lastname','One'),
'language':new DynamicProperty<String>('language','Italian')})];
this.ItemsSource = new ItemsCollection(columnDefs,items);
}
}
the template has some bootstrap css classes applied, but when it get rendered the css doesnt get applied in the component and here is what i get
the first table is from the component and the second is an html table and both have same css classes applied, so why doesnt the css classes get applied to my component?
When you have added the Bootstrap CSS to the page it won't work. The Angular.dart components by default create a shadowDOM around your components content. Bootstrap doesn't support shadowDOM and the selectors won't reach into the shadowDOM.
You can either set the attribute useShadowDom: false (like selector, publishedAs, ...) which creates components without shadowDOM
or you can add the Bootstrap CSS to the component using the attribute cssUrl which makes them scoped styles. You need to add this to every component. The browser should recognize it's the same URL every time and fetch the file only once though.
Related
I tried to include the Column Selector Widget to a table and it didn't work. After a couple of hours i found out that in the demo file itself and the the given html template it differs. On the working demo the table begins with two header rows:
<tr class="tablesorter-ignoreRow hasSpan" role="row">
<th colspan="2" data-column="0" scope="col" role="columnheader" class="tablesorter01e6b87093a1e8columnselectorhasSpan" data-col-span="3">Student</th>
<th colspan="3" data-column="3" scope="col" role="columnheader" class="tablesorter01e6b87093a1e8columnselectorhasSpan" data-col-span="4">Courses</th>
</tr>
<tr role="row" class="tablesorter-headerRow">
<th data-priority="critical" data-column="0" class="tablesorter-header tablesorter-headerUnSorted" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" style="user-select: none;" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort"><div class="tablesorter-header-inner">Name</div></th>
...
</tr>
but in the HTML template it is instead only one header row
<table class="tablesorter custom-popup">
<thead>
<tr class="tablesorter-ignoreRow"> <!-- Ignore all cell content; disable sorting & form interaction -->
<th data-priority="critical">Name</th>
So if i get it right, the template cannot work at all, because the first (and here the only!) header row has a "tablesorter-ignoreRow"-class given.
When using the sourcecode of the page it now works for me mostly, but the colspan of the first row which includes "student" and "courses" is now confusing me. Is it right that i have to set the colspan and data-col-span-values to the highest possible number of columns in it?
Thanks for any help!
I discovered that when loading bootstrap more than once the selector just doesn't work. Also when you mix bootsrap libs. So far I have not found the real problem. So I would search for the load order of the bootstrap libs
I have a Reports Menu in an ASP.NET MVC5 application. On the Reports Menu, I have an Html.DropDownList showing a list of programs. I want the user to select a program, and then click "Run" and post to something like: Reports/ClassList/14. In other words I want new {id=???} to contain the selected dropdownlist id.
<table class="table">
<tr>
<td>Choose a Program:</td>
<td>#Html.DropDownList("ProgramId", String.Empty)</td>
<td></td>
</tr>
<tr>
<td>Class List</td>
<td></td>
<td>#Html.ActionLink("Run", "ClassList", "Reports", new { id = ???})</td>
</tr>
</table>
How do I "insert" the selected ProgramId from the dropdown into the link parameters when the page posts?
Do I need to use JavaScript for it?
Thanks,
Sanjeev
Add a class on ActionLink:
#Html.ActionLink("Run", "ClassList", "Reports", new { id=""},new {class = "ClassList"})
Html generated for it will be this:
Run
and write dropdown change event and set id it:
$('select[name="ProgramId"]').change(function(){
$(".ClassList").attr("href",$(".ClassList").attr("href")+$(this).val());
});
and after appending with jquery it will become:
Run
I am working on a Rails 3.2.11 app using angular 1.0.5.
Currently, a user will select a Cycle from a dropdown, and that will return a bunch of JSON from my controller using ng-resource.
Here is the method
$scope.update = function(cycleId) {
Cycle.get({action: cycleId}, function(resource) {
$scope.selectedCycle = resource;
$scope.tasks = resource.tasks;
$scope.newTask = {cycle_id: resource.cycle.id};
});
};
Here is an example of what json my controller is returning, which is 'resource' in above function: https://gist.github.com/anonymous/01ffe5a37e370661f6fb
Basically I am needing to use ng-repeat twice (one of them nested) using angulars ng-repeat, so that I can get the task_type_name in there as a header. I'm getting some weird interesting results. See the shorted code in my view below and the full thing here
<section ng-repeat="(task_type_name,task_type) in tasks ">
<h2>{{task_type_name}}</h2>
<table>
<tr>
<th>Task Name</th>
</tr>
<section id="task-edit">
<tr ng-repeat="task in task_type">
<td>
<%= link_to "{{task.name}}", '', "ng-click"=>"toggleShowHistory(task.id)" %>
</td>
</tr>
</section
</table>
So my is occuring at this part here
<section id="task-edit">
<tr ng-repeat="task in task_type">
If I try to combine that section and tr, OR change tr to ANYTHING but a tr, {{task}} no longer becomes available.
<section class="task-edit" ng-repeat="task in task_type">
{{task}} is available right here
<tr>
{{task}} is not available right here
<td>
{{task}} is not avaiable right here
</td>
</tr>
</section>
I tested the same concept on the first loop, and it seems to be fine on that loop just not the second, nested loop.
I'm assuming it has something to do with the scope. But i'm just not getting it.
Also, if you have any tips, i'm very new to angular and would love them.
I created a demo, and I am not seeing any issue. Please check your data source and make sure you plug in the tasks value of the json.
You need to change the nested section to tbody.
Demo on jsfiddle
I have an ASP.NET MVC 4 web application. On a web page, I have a HTML table presenting a number of items.
I want to be able to implement drag and drop re-ordering for the table of items, which is saved back to the data model.
I've looked at and tried a few different methods for doing this, using JQuery UI and some other plugins but I haven't successfully been able to implement the functionality.
I've looked at this example, but my table didn't change on running it after implementing it as follows:
<script type="text/javascript">
$(document).ready(function()
{
$('#clueTable tbody').sortable().disableSelection();
});
</script>
I have all the necessary javascript:
<script type="text/javascript" src="~/Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui-1.10.2.min.js"></script>
I'm not going to post the whole table, but it looks something like this:
<table id="clueTable" class="grid">
<thead>
<tr>
<th>Clue #</th>
<th>Location</th>
<th>Quiz Clue?</th>
<th>Actions</th>
</tr>
</thead>
#for (int i = 0; i < Model.Clues.Count; i++)
{
<tbody>
<tr>
<td>Number</td>
<td>Things</td>
<td>Yes</td>
<td>Stuff</td>
</tr>
</tbody>
}
</table>
The duplicated tbody tags are your problem.
Works:
http://jsfiddle.net/vR9UW/
Doesn't work:
http://jsfiddle.net/vR9UW/1/
I have the following table structure inside a view which gets displayed in the _Layout view in place of #RenderBody
<table>
<thead>
<tr>
<th>first</th>
<th>second</th>
<th>third</th>
</tr>
</thead>
<tbody>
<tr>
<td>1st</td>
<td>2nd</td>
<td>3rd</td>
</tr>
</tbody>
</table>
In my _Layout page, I want to apply the contextMenu event to the th elements, however, being a beginner, I'm having a hard time figuring the selector for the same.
Some combinations that I've tried -
I have a reference to my table in a variable called oTable
oTable.$('tr th').contextMenu ....
oTable.$('thead tr th').contextMenu ....
$('table.tableID th').contextMenu ....
None of them are working. Any suggestions?
If you simply want to select ALL of your th elements then you don't need anything more complicated than this:
$('th').contextMenu ....
If your table has an id associated to it then the following will allow you to target just that table:
$('#yourid th')