Htmlstring table not working in the Open Data Tables - yql

I found several references online about the YQL HTML table that is no longer supported by Yahoo.
And so I replaced it with the new "htmlstring" table.
When I try to launch a select including the new htmlstring table in the console in the following manner:
Select * from htmlstring where URL='myurl' and xpath='/div[#class = "className"]'
The correct result is shown in the result panel.
However my code using the old HTML table is originally included in an Open Data Table.
And so I modified my Open Data Table replacing the HTML table with the new htmlstring in the data table code like in the following piece of code of example:
<meta>
<sampleQuery>
select * from {table} where url="http://myurl" and wparams="1,2,4,5,6" and xpath='//div[#class = "className"]'
</sampleQuery>
</meta>
var results = y.query("select * from htmlstring where url=#url and xpath=#xpath", {url:url, xpath:xpath}).results.*;
Unfortunately in this last case the query launched by the y.query () method return a null value, while the old code referring to the old HTML table, worked fine.
Why does the new htmlstring table not work if included in an Open Data Table while there are no problems excluding the Open Data Table?
Is there any reference I forgot to include in the open data table's code?

Related

Thingsboard input String widget

i'am working with thingsboard as a plateform to supervise my sensors ,and i want to know if there is any way to add in my dashboard a field that allow me to write comments and those comments will be written in postgresql database ?
i Tried to use input widget but it dosent work
it's a bit harder to make comments that will not overwrite previous comments since you would keep those comments under server attributes (you can't work with postgreSQL directly from ThingsBoard).
Solution to that is that you have input widget and then RPC call to rule chain where you would need to have some script that would put new comment as new field to the JSON array. This obviously requires a bit advanced knowledge about TB.
Also you could probably do that thru "Custom action (with HTML template)".
UPDATE:
The easiest way you can have comments :
Create JSON server attribute on entity (Device, Asset)
(Optional) Create filter that will return only one entity
Create "Update JSON attribute" widget and point it to the server attribute of entity on which you have done first step (help your self with step 2.)
a. have something like this in that window: {"comments":[{"ts":1665472792000,"value":"My comm1"},{"ts":1668163473000,"value":"My comm2"}]}
Create "HTML Value Card" widget, which also points to that entity and it's server attribute
In "HTML Value Card" widget use this code in server attribute post-processing function:
var comm = parsed["comments"]
var returnValue = '';
if (comm){
var commLength = comm.length;
}
for (var i=0;i<commLength;i++){
returnValue += "<span>"+comm[i]["value"]+"<span><br>";
}
return returnValue;
This code in HTML of "HTML Value Card": ${nameOfYourServerAttribute}
Yes, you will have to manually add comments directly to JSON, I don't have time to write some widget for that.
Take a look at my example:

replacing the tag data with data saved from sql

I have a mvc controller which have a static page with table html tags. Now I have datas saved under sql which I wanted to replace the data.
For instance, I have a this kind of the view page Example then with the help of cs file I can change the header or footer for instance based on the data from database
How can I be able to modify the tags? As I am new for this I need some guidance regarding this?
Just a request if you think this not a related post then instead degrading it please let me know I will delete it.
Trying using ViewBag or ViewData from the controller to display values in the table, then use a conditional in C# Razor to check the data and modify your tags based on what comes from the ViewBag and ViewData.
More information here: http://weblogs.asp.net/scottgu/asp-net-mvc-framework-part-3-passing-viewdata-from-controllers-to-views
Another option is to use JavaScript to check for values from POST method.

Creating and Editing related entities from a ASP.NET MVC web form

I'm creating a ASP.NET MVC 4 web app with a database and Entity Framework 5 for a web form to maintain Document (aka Contract) entries.
Below is a sample ERD (in the form of edmx diagram with navigational properties) I have created for a DB in SQL server. For MVC web app the Model is generated from the DB with .edmx file.
Based on the Model, I have setup a form which can create and edit a Document like so:
Document Create and Edit View
This view refers to Document model class. So all the input fields using html helper (Html.TextBoxFor...,etc) are referred from Document object and its related objects (Section 1 & Section 2). The checkbox hides and shows the subform for a section with JS/jQuery. For the Edit view I use same as Create view, except it contains additional hidden ID fields to identity the records to edit from the DB.
I have added a variable length list for section item addition by following this:
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/
In the partial view for the items dynamic list I use Section1Item and Section2Item as model reference.
Document Controller's Create method
So on Create the document object posted in Create(...) method contains all the attributes from the Document including the section's attributes.
If the checkbox value for Section 1 & Section 2 are false then I set the Document's Section 1 & Section 2 to null like so:
if (section1_chkbox == false) {
document.Section1 = null;
}
I have to add each item from the dynamic list into the document object like so:
foreach(Section1Item item in itemsList) {
document.Section1.Section1Items.Add(item);
}
So finally the Create method in the DocumentController adds the document in a db context and saves changes. The document and its related entities are successfully added to database tables.
Document Controller's Edit method
But when I'm editing the document with the Edit method in DocumentController there are some inconsistencies with some section1 object's ID being null for some related objects in Section1Items. For example when Section1Items are present the posted Document object (for edit) does not contain reference to Section 1 object's ID.
So it is fiddly and messy to update an existing document record as I'm having to check the ID attributes of a object. There are always errors like inconsistent principal and dependent objects in the relationship when saving or setting the object's entry state to modified.
My Question
How can I setup the View and Controller to achieve a functioning Create and Edit of a document along with its related entities as in the form's interface able? I need a efficient and correct way to use Entity Framework for this. How can I use view models for this if that would make this easier?
From what you described here I understand that there is a problem with virtual reference to Section1 from Section1Items. So in other words the problem is that entity framework model doesn't suit you display needs. You would need to render duplicated entities to map entier Document in your view. Am I right?
If that's the case I see two solutions:
like you suggested use view models to solve the problem. If you confirm the issue I can try to write example view model.
serialzie/encrypt entier Document in your view and next merge edited result with encrypted Document. You can achive that by using Mvc3Futures feature.
Serialize and encrypt your document in view:
#Html.Serialize("Document", Model, SerializationMode.EncryptedAndSigned)
And to deserialzie and decrypt you can use:
public ActionResult Edit(string id,[Deserialize(SerializationMode.EncryptedAndSigned)]Document document)

Creating Drop down list for a column which is defined as an Int in the SQL database - jqGrid ASP.NET MVC

I am using Entity Framework Database First approach in ASP.NET MVC.
I have created models from an existing database and everything works fine.
I am using jqGrid and trying to create a drop down list for a column which is defined as an Int in the database.
In the database, the values are either 0 or 1, so in the dropdown list I will have to show two values such as "Import" or "Export" based on whether it is 0 or 1.
Would I be able to handle this scenario in the jqGrid?
Please post any suggestions if you have!
I think you can handle this thing in colModal itself. there's is one option editOption you can specify with you colModal and based on the value you are getting from data you can specfy the text property of that column
In this case, the data for the grid should contain “One” or “Two” to be set in the column myname.
Now, with this setting
<script>
jQuery("#grid_id").jqGrid({
...
colModel : [ {name:'myname', edittype:'select', formatter:'select', editoptions:{value:"1:One;2:Two"}} ... ]
...
});
</script>
the data should contain the keys (“1” or “2”), but the value (“One”, or “Two”) will be displayed in the grid.
check this link for further help. You will get your answer. Because you didn't post your code(atleast you should have done that for ur that particular column) i can not say you are implementing the same way.

extbase mapping to an existing table doesn't work

I've extended the pages table and now I want to use some of the data in a domain object called "Tags".
So I tried the following in the /Configuration/TypoScript/setup.txt:
plugin.myextension.persistence.classes.Tx_myextension_Domain_Model_Tag {
mapping {
tableName = pages
recordType = Tx_myextension_Domain_Model_Tag
columns {
tx_myextension_tag_name.mapOnProperty = name
uid.mapOnProperty = id
}
}
}
But It seems that the extension tries to access the table Tx_myextension_Domain_Model_Tag (which doesn't exist)
This is the error I receive:
Tx_Extbase_Persistence_Storage_Exception_SqlError`
Table 'tx_myextension_domain_model_tag' doesn't exist: SELECT tx_myextension_domain_model_tag.* FROM tx_myextension_domain_model_tag WHERE tx_myextension_domain_model_tag.id = '24' LIMIT 1
What have I done wrong?
Don't forget to include your extension typoscript template into your template ( template > edit whole template > include static templates ), otherwise your setup.txt is not evaluated.
To check which recordType(s) are acceptable use Configuration module in BE, in $TCA section find your table ([pages] in this case) and check type column (...[ctrl][type] - for pages it's 'doktype', which decides if page record is standard page or sysfolder etc.).
This column is tinyint(3) in database, so you can not write value 'Tx_myextension_Domain_Model_Tag' to it. Create in your ext new doktype identified by number and set recordType to it.
Optionaly you can just remove recordType from mapping config if page's type doesn't matter to you.
did you try "config.tx_extbase" instead of "plugin.myextension"?
Something like
config.tx_extbase.persistence.classes.Tx_MyExtension_Domain_Model_Tag.mapping.tableName = pages
works for me.
Tx_myextension_Domain_Model_Tag is the name of your object right ? But I guess this is not the name of the table you are trying to access. So my guess is that the name you are providing into the value "tableName" is wrong. What does "pages" contain ?
Have you specified the individual pages as recordtype Tx_myextension_Domain_Model_Tag ?
It's supposed to go into the doctype field of the pages table (therefore you'll need to change the mysql datatype of that field.
Otherwise Extbase doesn't know that this specific page is an extbase record and not a regular page.
See more about single table inheritance (STI) in Extbase: http://pascal-jungblut.com/blog/blog-post/2010/11/06/single-table-inheritance-in-extbase.html
do you do this in a typo3 call with eID?
here some configuration is not loaded ..
if yes, try if loading all configuration solves the problem:
...
$GLOBALS['TSFE'] = \t3lib_div::makeInstance('tslib_fe', $TYPO3_CONF_VARS, $_GET["id"], 0, true);
//$GLOBALS['TSFE'] = new $temp_TSFEclassName();
$GLOBALS['TSFE']->connectToDB();
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->determineId();
$GLOBALS['TSFE']->getCompressedTCarray();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->getConfigArray();
...
Take care of the proper naming convention regarding FE-Plugins:
plugin.tx_myextension

Resources