I'm playing with rewriting part of a web application in Rails + Ext. However, I'm having trouble getting an associated models' name to display in the grid view.
I've been able to successfully convert several models and arrange the views nicely using tabs and Ext's layout helpers.
However, I'm in the middle of setting up an association -- I've followed along with Jon Barket's tutorial on how to do this using Ext -- and I've made all the Rails and JS changes suggested (with appropriate name changes for my models,) the result being that the combo box is now being correctly populated with the names of the associated models, and changes are actually written correctly to database, BUT the data doesn't show up in the column, it's just empty. However, the correct data is there in the 'detail' view.
Really just wondering if anyone else ran into this, or had any thoughts on what could be happening. Definitely willing to post code if requested; just note that (AFAIK) my changes follow the tutorial pretty closely.
Thanks in advance!
UPDATE:
Alright, slight progress - kind of. I can get the associated model id # displaying properly -- just by modifying the column model slightly. But I can't get the virtual attribute displayed in the main table (in Jon's example it's country_name.) It still goes blank when I change the data source for that column from
dataIndex: 'model[associated_model_id]'
to
dataIndex: 'virtual_attributes[associated_model_name]'
ANOTHER UPDATE:
Bump. Has NOBODY here tried integrating Ext with Rails?
OK, I should've paid closer attention to the tutorial and how I was using the API and other information available.
If you're using tabs to distinguish between several grid views, don't neglect to export to json any helper methods (you MUST do this in the controller for the model) -- especially ones for retrieving associated models' name!
Related
I am a novice at best so much of this I have pieced together by trial and error. I'm sure there are a lot of issues and probably better ways of accomplishing what I am trying to do. Just need to figure out the data store issue if possible.
Here is a link to the current working code base:
http://www.keystone-360.com/Beta beta page
And here is the zip file containing all of html/js/css files:
http://www.keystone-360.com/Beta/beta.zip beta.zip
This is where model view controller comes into play. The fields and grids on the right panel will bind to the datastores. Stores are like tables in a database. They contain models which are like records.
The kitchen sink has a large section on data binding. The binding is the same more or less across the modern and classic tool kits.
https://examples.sencha.com/extjs/7.5.0/examples/kitchensink/?modern#data-binding
https://examples.sencha.com/extjs/7.5.0/examples/classic/writer/writer-jsonp.html
I am developing a .Net Core application using MVC in Visual Studio 2017.
I have been developing on it for some time, and 7 months ago I took a break. Now I have returned to develop further on it. Back then I "learned" that the way to render a view within a view was to create a partialView and render that using javascript/jQuery as follows:
$("#div_name").load(<some-url>, { id: <some-id> }, function() {
console.log("loaded successfully");
)};
I assume there are different "integrated" methods for doing this? I find it hard to believe that the only way to load a view within a view is by using javascript/jQuery. Does anyone have some knowledge to share? I can't seem to find anything on Google (but that might just be because I don't know what to search for).
I have been reading up on partialViews and have found that these "can" be loaded from Razor, but if I want to get data from my database context I am unsure of how this would go about. Furthermore found something called components which I will take a look into myself.
However my current problem is that I have a table in my view:
I want it to be that whenever I click a row inside that table I download some data from my DbContext (using my controller) and that data should be put inside a new view that is loaded within the first view so it would be like follows:
Right now it works when I use static "test" data that I generate myself, inside my controller, but not when I try to connect to my DbContext in my controller, even though I am using async calls, I get no data passed through the view.
I would think that .Net Core might have some other way to do this, as I think it is quite tedious to use javascript/jQuery to do this. Am I completely wrong?
EDIT:
After I did some error checking in my code I managed to get it to work (I had my input value to my Controller method receive an int when in fact the value passed was 15 characters long and started with a 3 (larger than the largest value allowed for an int). As soon as I changed the input to the method to a long it worked and I got my desired output. However I would still like to know if there's a different way to do this in .Net Core MVC.
I am just wrapping up a long term project I have done for a company, but I am really stuck at this point.
I have a cool little page here: http://hagen-etc.com/test/buy/
It is basically showing all their retailers in the right hand side div while you can narrow down the results with the different options on the left side (Javascript based).
Everything works just fine, but I have run into a problem. The thing is, the person I am developing the site for has absolutely zero knowledge about programming and website managment etc, and therefore I need a smart way for her to change it.
I have simplified the procedures several other places on the website using shortcodes with Visual Composer and Shortcoder-plugin.
The problem here is, The Javascript is in footer.php while the actual content is on a Page in the dashboard. How do I make a smart solution so she can easily manage this in a blink of an eye? You can take a look at the source code in the link above if you would like to.
Would love to get some help on this because I am having a hard time figuring out a solution. Maybe a plugin can even do this?
The different areas, countries, cities and retailers are written in HTML in the Page while reas, countries, cities and retailers are written in Javascript in the footer.php. I know I can move the Javascript over to the Page, but the problem is, she would still have to change both the Javascript and the HTML.
I would like it to work with Shortcodes in a structure like this:
[countryopen]
[areaopen]
[cityopen]
[retailer][retailer]
[cityclose]
[areaclose]
[countryclose]
How would I go about this? The HTML would be in the top of the file while the Javascript would be in the bottom. I cannot really change both things with just one shortcode. How would I do this or is there even a better solution?
So essentially you are trying to allow this person to manage locations? You can use Advanced Custom Fields for WordPress and/or custom posts types for WordPress.
I would use a combination. Create a new custom post type in your functions.php and then, after installing the ACF plugin, create Location, Area, City, and Retailer fields and assign them to the new post type.
Similarly, in the index "Page" that you are working in now, you can create a query to dump any of these Locations onto the page.
I hope this helps. Let me know if I missed the point here, the question is still a little unclear.
UPDATE: There are many great tutorials that will walk you through creating a custom post type in your WordPress theme. WPBeginner and Smashing Magazine do a really good job of bringing you through this step-by-step. It will be very helpful for you to know how to do this and to understand this as a basic part of WordPress's Model-View-Controller system, here you are creating new views for your users to interact with.
After creating your new custom post type, which will seem like any other post/page in the Edit view, you can use the ACF plugin to easily add new fields to this new custom post type:
In the second section called "Location" you can define what type of posts these fields should be appended to. You would make these inputs says:
Post Type is equal to [Your New Post Type]
Your new post type being "Locations" or "Retailers" or however you want to phrase that. Now, when you check out the Edit view of a new custom post type, you can see these new fields appended to the bottom. Lastly, you may want to remove any field that you wouldn't want your web manager adding information into like WordPress' native Description or Excerpt inputs. You can do this by adding a few lines to your functions.php after you have created the post type:
add_action('init', 'remove_editor_from_retailer');
function remove_editor_from_retailer() {
remove_post_type_support( 'retailer', 'editor' );
}
Granted that "Retailer" is the name of your custom post type.
You can't have a user updating data in a javascript file.
So what you need to do is split the data off from the functionality.
To do this, put a script tag in one of your Wordpress template files, and output the area, country etc. data there as a Javascript variable.
You can manage and fetch this data using any Wordpress method of your choice. Anything that allows the user to update data in the admin area which you can then output in your plugin will work. So a plugin, a shortcode on some specific post, etc. are possibilities.
Then, in your existing Javascript file, remove your hardcoded data and instead pull it from that variable.
Again, let me start this by thanking for your time to read this and second by apologizing for not being able to actually paste my code.. it's located on a computer that doesn't have internet access.
I am working to add an icon to a systray in a web application. The icon changes based on values contained in the model. The systray is has a controller located say
myproject/myjs/main/controllers/systraycontroller.js
myproject/myjs/main/models/myniftymodel.js
myproject/myjs/main/mainModule.js
I want to update the model based on user choices on a different page that also has a controller and it's own module
myproject/myjs/colors/colorsModule.js
myproject/myjs/colors/controllers/colorsController.js
My question, what exactly is required in colorsModule.js to get colorsController.js to be able to not only see myniftymodel.js but update it?
myniftymodel.js is just a simple model that returns a values array and is used by the DIV in systray.html to display info about the icon.
I recommend that you wrap the model in a service. Use one of the various providers offered by Angular.
https://docs.angularjs.org/guide/providers
You can then dependency inject the service anywhere you like in your application.
I am pretty new to Ext-JS.
I have a form in view which contains a table layout with two columns. One column contains another table layout with three text fields, a button and a grid panel.
I have a controller which has a listener for button(inner table layout), I am using a Ajax Request and need to pass values of three text fields as Params. I tried several ways but cannot pass param values.
I almost researched a day and found different ways like using Ext.getCmp method but none of them really worked.
From my past web experience, I am thought we need to access form and its elements from its id or name, but it didn't worked.
Can someone point me to some good resource to understand Ext-Js Architecture and Forms.
Thanks in Advance.
If you are using ExtJS 4.0 the following link:
http://dev.sencha.com/deploy/ext-4.0.0/examples/form/xml-form.html
provides a good example with source showing how to load and save data through AJAX requests and an Ext.form.Panel component. Other form examples can be found at this link:
http://dev.sencha.com/deploy/ext-4.0.0/examples/#sample-13
These example links are both from Sencha's website so they both should contain examples implementing best ExtJS practices.
Finally I got it, Patience Wins! .
var win = btn.up('window'),
form = win.down('form');
form.getForm().findField('NamePropertyValue').getSubmitValue()
The above code worked.