Is it possible to add totals to observablehq inputs.Table - javascript

Is it possible to add a total row in inputs.Table from Observablehq? The idea is to have a column aggregate such as sum or mean. I searched through the inputs.Table documentation, but it does not seem to mention this option. In addition, I could not find any notebook showing this option either. If this option is not implemented in inputs.Table, do you believe it is feasable to improve the source code to have this functionality for someone relatively new to JavaScript? I had a look, and was kinda of lost in the source code, but maybe with a little guidance from someone more experienced, I could be able to modify it by myself. Alternatively, how can one add the totals using an external library?

This isn't something that inputs.Table supports directly. I'm not sure if it is something that the maintainers of that library would want to include, but it is an issue that has come up before: https://github.com/observablehq/inputs/issues/148. I think you could post there to try and get some guidance about how to move forward.
Another thing you could do is to modify the data you are passing to the table to add those rows. I made an example of that: https://observablehq.com/d/ed915b04358db27c. There isn't a way to style those rows separately though.

Using an external library, one can easily generate a table with totals. An example of such a library is Tabulator. Here is an example notebook.

Related

jQuery DataTables altEditor issue

I've been trying to get this free alternative editor I found here to work but it keeps on blowing up on me because I am terrible at javaScript. Been debugging, reading documentations like mad all day but my scrub mind is out of ideas but I'm still trying anyway.
I deleted some of the stuff it had in there like ajax to server,the ID row, because I don't need those, I just want to be able to insert, edit, and delete rows in the table while keeping the <option> dropdown and pattern validation.
I prepared a jsfiddle with my exact setup here. Any hints/help will be greatly appreciated.
Managed to figure it out myself.
This jsfiddle is an updated version that works.
This diff shows the modifications I made compared to the original.
What is the point you ask?
The point is to be able to validate stuff before adding/editing them, to have a neat dropdown select, and to be able to send the data from the table itself as a JSON string in a "Column Name" : "Cell Data" format so that I can json_decode($_POST['table'] and use a nice associative array to add the data to my database.
Why?
Beats me, do what you want with it. I plan to use it to send a list of addresses one way only to the server.
Why not use the official editor?
Because I can't justify the price for my meaningless project and I hardly need 10% of what it offers.
Big thanks to Kingcode.com where I found the free datatables editor alternative and KasperOlesen for making it more awesome.

Moving DataTables pagination length dropdown

I'm trying to move the dropdown that DataTables uses to determine how many rows to display. One way I thought of was to use jQuery's prependTo()/appendTo() functions, but it feels a bit too hack-y. I tried searching through the DataTables API to see if there was some native way of doing it, but I couldn't find anything. I was wondering if there was a better way to do this.
This is basically what I'm trying to do: http://jsfiddle.net/jbZG7/
$("#tableID").dataTable();
$("#tableID_length").prependTo("#new-div-id");
Thanks!
I created a custom dataTables widget which combined jQuery UI Dialog with DataTables. I too needed to move dataTable controls to custom locations, which could not be accomplished with sDOM very much in the same way you need to.
When looking for a solutions I was concerned about .appendTo/.prependTo being too hacky, but as it turns out .appendTo/.prependTo are the best solutions I have found.
$('tableID').dataTable({
fnInitComplete : function( oSettings, json ){
$("#tableID_length").detach().prependTo("#new-div-id");
}
});
Updated jsFiddle
fnInitComplete
Open the dataTables.js file. Look inside and see if you can find anything related to paging. I did a CTRL+F and typed pagination. You want to look for information on where the pager is drawn.
Also...using firebug to set breakpoints in the dataTables.js file might be a big help too.

Create a textfield which can include html markup

I was wondering how one could create something that resembles a textfield, but can contain html elements in it. For example, something like what Stackoverflow uses for tags on its "Ask Question" page. Can this be done this done using a particular plugin/library or does it need to be created from scratch?
I have seen some solutions using the "contenteditable" property, but I am worried about cross browser compatibility. In fact it would appear that the Stackoverflow example does not use this. I have tried searching for info on how to do this but haven't found anything. Would be grateful if someone could point me in the right direction.
You don't need to create it from scratch. Here is the one I use: TinyMCE
You might also find this useful. But you dont need to make a new one. There are a plenty of open source options available.

UIAutomation, UITableView inside UITableViewCell

I have a horribly coded set of controllers which I am unable to refactor at this time. I need to bring them under automated testing, but have run into an issue with the UIAutomation tool.
These controllers are dynamically generated. There were many ways to do this but somebody decided it would be best if they made a tableview containing cells which each contain more tableviews, containing the cells that the user will see and interact with.
A simple example of one of these controllers is as follows:
I need to press one of those table view cells automagically.
After struggling with some view hierarchy issues, I finally managed to get the logElementTree to see all of the cells, with correct accessibility identifiers. Here is the result:
Now just to test that I can press one of the buttons from a script...
NOPE. I can't seem to drill down into the elements even though the logTree clearly shows they exist and are visible.
Any ideas very welcome. I'm not very experienced with javascript so I could be missing something obvious. Thanks!
To answer my own question and thanks to a helpful engineer at the WWDC:
target.frontMostApp().mainWindow().tableViews()[0].cells()[0].tableViews()[0].cells()["Open"].tap();

How to create 2 Image rotation carousels on the same page using one jquery script file

new to jquery need help please!!... - I'm trying to create two carousels on the home page using the example below but doesn't seem to work.
I realise that the example is using ids, tried to change them to classes but didnt it do much.
http://www.dreamcss.com/2009/04/create-beautiful-jquery-sliders.html
Thanks
An important philosophy in jQuery is "Don't reinvent the wheel."
Just use a plugin for features like this, such as Easy Slider!
Here's a demo of more than one on a single page
Oh, and in the future, be sure to describe what doesn't work as well as your code if you want people to actually be able to help you with your specific problem.

Categories