Building a JavaScript grid from scratch [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am curious to know what it takes to build a JavaScript grid from scratch. The grid should have features like jqGrid http://www.trirand.com/blog/jqgrid/jqgrid.html.
Can anyone please give me inputs?
Thanks

What it takes to build something similar to jqGrid:
A huge, HUGE amount of time.
If something similar to what you want exists already, why would you want to spend lots and lots of time re-inventing the wheel? Anyhow, if you have nothing better to do, want to learn from it or if you are just curious, here is a list of skills that are needed to create a similar system:
HTML object manipulation.
Style manipulation.
Tons of different event handlers.
AJAX to grab (pages of) documents to display. Probably some server-side stuff too...
Creating of a nice layout system wich works in every browser.
Creating handlers to read and manage the different file types to support (XML, JSON, etc)
Creating HTML forms and reading them out with JS and then use AJAX to resave an XML, JSON, etc document back to the server.
An Algorithm to allow searching in the data you display.
Keyboard manipulation and the toggling off of standard key-events.
10. Tons and TONS of debugging to make sure it looks nice in all browsers.
Of course, this is only a tip of the iceberg since I don't really know the jqGrid program myself. I created this list by looking at some of the examples and reading the Features page.
Again, I would not recommend to rebuild such a big system from scratch, but the choice is of course yours ;).

Related

Similar and simplified examples (newbie questions) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm currently studying about web development, I still don't know about jquery, but I've a little knowledge about javascript, html and css (basic).
I've been looking at some examples in github to improve my skills, and I've found this content;
https://github.com/stewilondanga/editables
I perfectly understand the theory, but I do not know how to put it into practice, I would like for any similar examples (simplified alternatives) and how to convert the exported code generated by javascript into a html5 table?
Any example would be appreciated! thanks for your attention!
First of all, jQuery does not generate code. It's a framework, you load it into a web page, and then you can use it from within Javascript code in that page.
I suggest you start by looking at the source of https://stewilondanga.github.io/editables/, if an editable tables is what you need. There are more general frameworks to do this, e.g. Aloha
To try it yourself, I'd suggest you bite the bullet equip yourself with some kind of web server, be it on a server somewhere, or on your local machine, so you can easily try out things like this, copy the sources, alter the code etc.., and quickly hit reload on your browser.
While it may seem easier to run a local server and point your browser at http://localhost/something, IMHO it also takes more tinkering to get browsers to embrace that fully. You don't need the extra grief while already learning all those new concepts. If you want to tackle this seriously, consider getting a hosting service or small VPS somewhere. If you don't know how to do that, get help for that first, but get it out of the way. It'll save you much grief.

Creating table using C# vs using Javascript/jQuery + Json [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
This may look like an opinion-based question but the reason I am asking this is to come up with an explanation on why I should use the other versus the other.
Scenario:
I am a new intern in this company where they have lots of ASP.NET MVC projects and one thing I noticed is that they are building a large row of tables using c# foreach loop like so:
#foreach(var i in Model)
{
<tr>
<td>#i.Name</td>
<td>#i.Amount</td>
<td>#i.SomethingElse</td>
</tr>
}
And I made a comment to my co-intern that it looks "stupid" and it makes the server do unnecessary workloads that can be done with javascript (so the workload is passed on to the client computer instead).
Then I didn't notice that the company developer was behind us and told me to prepare a list of reason how I can improve it and why I think that their "way" is stupid.
I am somehow new to programming and do not really know the ins and out of things but I know something is wrong with such practice (or not?). Can anyone give me a solid argument or explanation why I should pick the other over the other one?
"There is nothing wrong with this". That is the first thing I can confirm with you.
Even though I recommend you to read more about MVC, but in short, it doesn't increase the workload for server.
With MVC, there are 2 ways (as I know) to display data.
Traditional way like your company. Loading every data to a Model, and using View to display Model. This is how MVC design pattern work.
Return all bunch of datas to an interchange format (json, xml, but mostly is json), using Java-script to display those data.
Since I said there is nothing wrong, there will be pros and cons, and Method_1's pros is Method_2's cons: (in my opinion, will update more after research on other pros and cons)
Pros:
With method 1, it will be easier to control with Razor syntax / C# syntax.
Correct format of MVC.
If using Method_2, you may need to copy-paste a lots of JavaScript if you have similar pages on same projects
Cons:
it will be complicated when you are required to load more than one Model in a View.
Does not apply if you has multiple Front-end.

Web Scraping - What's a robust and extensible approach? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have some limited experience with web scraping using tools like Beautiful Soup and Nokogiri.
My approach thus far when looking for information is to first inspect the HTML elements and CSS tags, then applying the selector. While this works, slight differences/changes among web sites would render the code useless. Also, there have been situations where sites simply don't add the selector tags to their HTML elements, so I once had to resort to the hacky approach of selecting the style property of the element.
How would one devise a scraper that would work across multiple sites? I'm aware that the solution would depend on the context, but is there a general good practice in doing it? I was actually asked in an interview before this question and I had no idea.
I have tried googling but much of what I found doesn't go past the basics, and I don't know where to look. Any help would be appreciated.
It's not clear from your question what exactly you are trying to accomplish. If you want the content of the page (like in an article) - you should try goose, which should give you a leg up. You can also try searching for conventional web page approaches like meta tags.
Either way, you should remember that this is the World Wild Web, and the HTML is a very forgiving language, which lets people design pages which are very hard to read by a machine. Even big sites sometimes have their proprietary breaks from conventions, which forces exceptions in your code in order to read them. Site logic may also conflict with conventional logic, or other major site.
This means that your code would probably consist of a lot of use-cases and exceptions.
My suggestion to you is to keep samples of pages of sites you want to scrape, and have a unit test which iterates over them and verifies the scraping results. This way, each time you find a new quirk, you can add it to your collection, and be certain that if the change you made broke some other site's scraping, you would know about it.

Looking for Javascript calendar that will embed in a web page and get data from PHP/MySQL server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I've been hunting for a long time for this, but despite my intuition that this would be a common thing, I haven't encountered anything that meets my requirements.
I just need a month calendar that I can display in a web page which will show events. Each event just needs to show the name, and that name will link to another page.
The calendar needs to be large and readable, something in the neighborhood of 600 or 800 pixels wide. I should be able to colour the lines and text and so on with CSS. Should not rely on any image files.
Data needs to be pulled from the server via JSON. I have an existing PHP/MySQL set up on the server side, and I can write the PHP to accept and send the right JSON data. I only need the Javascript side of things.
The reason I have not found anything like this is because the calendars I have found have fallen into two distinct categories:
One are calendars that are build with the intention of having people interface with the calendar and add, share, or edit events. I strictly only need to display (events in my case are added to the database via a different interface). The amount of code overhead for that kind of interaction makes them way too huge and unweildy to edit down to my needs.
The other type of common Javascript calendars are the types used in forms, that are often seen in drop downs, used for picking a single date. These are obviously too small and are in any case too different from what I need to extend to my purposes.
I can edit Javascript, but building an entire Gregorian calendar with all the little mathmatical tricks to account for days and rows and columns in a table representing a month seems like reinventing a very complicated wheel.
Perhaps I am using the wrong search terms or something. Are there any existing code bases available that do what I hope to acheive?
Free and/or open source is of course the ideal, but I will consider purchasing if necessary.
I assume you already know jQuery-based FullCalendar as it falls into your first category, but I still think it's a superb choice. You can disable all the interaction abilities, and it's widely customizable.
It has day, week, and month views, can pull data via Ajax, and displays multiple-events (and multiple-day/week events) beautifully.
There may be a leaner solution out there that does the same thing but I don't know of one.

Is there a guide about how to create beautiful HTML that is preped to be used with javascript? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
This might seem like an odd question, but I find that javascript is either easy or hard, depending on how you've coded the HTML. Is there a book or website that goes into detail about successful patterns and guidelines for coding HTML, so that it's very workable with jQuery, css and complex ajax applications? Like solid rules to live by.
Again, seems like a weird question maybe, but I don't know a better way to ask it. I just find myself always having to change the markup as new things come up - like switching between a hidden input element to a data attribute... or putting more ids or taking away ids - and I guess I arrive at the right way to do it, but I'm curious if someone has bothered to analyze this and came up with some great guidelines, standards and patterns so that the resultant HTML is right the first time.
Thanks
The first thing if you want to code some clean HTML that will be easy to work with is to make sure that your code is valid against an official DTD, HTML4 (here) or XHTML (here).
Then use id and class in a proper way (id only for unique section and class for repeatable ones) and name them correctly according to the context so they are easily reachable.
From my experience, I would actually suggest that, when it comes to large projects and professional JavaScript coding, the goal actually becomes to decouple the JavaScript code from whatever HTML it lives in.
As mentioned already, as long as you are using well formed HTML (DTD compliant), a library like jQuery shouldn't have any trouble operating on it. However, as best practice, I would recommend striving to isolate and encapsulate dependencies, whether they be because of HTML structure or just other chunks of JavaScript code.
the best way is to develop the html and javascript together. That way you can adjust the document structure to whatever you need.
This article seems to answer my question:
http://www.viget.com/inspire/extending-paul-irishs-comprehensive-dom-ready-execution/

Categories

Resources