Share object between two componets in Blazor - razor

I'm trying to get an object from one component to another in Blazor. For example, in the first component, I will retrieve data from database and in the second component, I want to display them?
I found solution for sharing value but not the whole object. Is there any solution for this problem?

Related

displaying images referenced in mysql database using react

i've seen an example where one uses the map method to 'extract' images from hardcoded data (eg an array containing image paths) to display pictures on a webpage.
i'd like to do something similar except this data which is now external sits in a mysql database.
my thinking is maybe there's a way to import mysql data into an array variable to expose this data to the map method, mimicking the hardcoded scenario? just looking to see if i'm on the right track or whether i should be barking up another tree.

loading large JSON file data into angular cli table

I have a JSON file with more than 200000 records in it.
I'm using Angular CLI for accessing JSON data with the help of json-server API for accessing it locally.
Im using Angular http request to access JSON, it is getting displayed into browser but not into angular table component.
I checked if ill be able to access it with less number of records then it got displayed, with upto 1000 records i have checked but max i don't know how much it access.
so i just want any solution for accessing large JSON data into angular view efficiently.
please suggest any solution or alternative for the same.
This may be opinionated answer but you've many options.
Try lazy loading table data.
Implement Infinite Scroll by loading 50 rows initially & when user reach end of table, load next 50 and so on. Use following plugin for that to minimize your code.
ngInfiniteScroll
Add pagination to table by using custom filter on ngFor to filter out elements with their index no. You can use following awesome plugin lib
ngx-pagination
Make use of grids. This is best performance, reliable solution. There are many grids like ag-grid, slickgrid, Angular data table, etc use according to requirement. ag-grid is Angular supported and slickgrid is pure js grid but you can surely configure inside angular project. Also you can try data tables from PrimeNg.
With using grids, searching, filtering, exporting table data becomes very efficient.
ag-grid
Angular DataTables
SlickGrid
PrimeNG Table

How to create empty data table using PrimeNG

I am creating a UI that allows users to input data in batches.
Similar to an Excel spreadsheet but the columns are already fixed.
I'm already using PrimeNG DataTable for other parts of my web app, and I would like to continue using it for the aforementioned feature if possible.
Thanks.
I figured it out.
My initial code was correct but because there was an issue when the backing array of the data table was being updated via push.
I had to create a separate array with the empty objects and assign it to the backing array.

Configuring Object Instances from JSON in conf Files

So I want to be able to basically make instances of a class from JSON definitions in a conf file. In looking through the docs, I found that there are ways to reference things that are defined in JSON structures, but I was wondering about how best to instantiate objects from such definitions. For instance, suppose I had a class called RemoteRepository with 4 or 5 properties. I'd like to make a bunch of entries in a JSON file then read in at startup and get back a collection of RemoteRepository objects. I could do this with a database, of course, including a graph one, but would like to just do JSON if possible.
Assuming a static class definition that represents the JSON structure is acceptable, you can try the JSON C# Class Generator
Once you've generated your classes you can simply create a new instance or array of instances by passing in the json to the constructor that this tool creates on the generated class(es).
So I can make instances, but as usual, once I need a bunch of instances, it's time for a database. In this case, I ended up doing some simple XML files to trigger these instances. As much of a mess as XML is, for things like this, it does work best. Namely:
Some nesting of instance information
Not an exact mapping to the target class, e.g. field mappings are part of my config. I am going to load a few fields from the config file, but then create instances of a different class, hence the immediate conversion to a java class I would get from JSON is not meaningful
One other thing I figured out in doing this is that processing XML in Java is still kind of a mess. Still, this was the right way to go in this case.

Automatically generate static html files containing the output of the corresponding view of model objects in Rails?

I am just wondering whether there is any work regarding the generation of static html files containing the output of the corresponding view of model objects.
Such an approach should also be able to regenerate outdated html files in case model object content changes.
I have done some research but couldn't find any appropriate solution...
Your question is very hard to parse–some steps/examples of what you're trying to accomplish would help.
"output of the corresponding view of model objects"
Model/objects don't have corresponding views–actions (in controllers) do. I'll assume you're talking about basic CRUD/scaffolding views related to your models.
If that's the case, take a look at render_to_string. It's basically renders a view to a string instead of to the browser.
So, if you wanted some "automatic" generation of html files, you could have a special controller action that loaded some models, looped through them, rendered a view for each to a string, and then saved that string to an HTML file using the model's ID and a time stamp as the name.
If you wanted to get really automatic, you could then call the URL of your special controller action daily/weekly/monthly from a cron job using wget (with some authentication, natch).