zinaw Tesemma Posted January 22, 2020 Share Posted January 22, 2020 Hello I am able to generate a dynamic html table with input field using Ironpython script as below, this html reside inside a loop... ...... ....... html += " "+value1+"" html += ""+value2+"" html += ""+value3+"" html += " Link to comment Share on other sites More sharing options...
Tyger Guzman 2 Posted January 22, 2020 Share Posted January 22, 2020 You can use a python script attached to your submit button. The Python Code may need some alterations to account for your but its working for a static HTML Table . from System import IO from System.Text import Encoding from System.IO import Path, File, StreamWriter from Spotfire.Dxp.Data import DataTableSaveSettings from Spotfire.Dxp.Data.Import import TextFileDataSource from Spotfire.Dxp.Application.Visuals import HtmlTextArea from Spotfire.Dxp.Data.Import import TextDataReaderSettings vis0 = x.As[HtmlTextArea]() mytext = '' for z in vis0.HtmlContent.split('n'): if "" in z : mytext += '"' + z.replace('','').replace('','') + '"' + ',' if "" in z : if mytext.endswith(',') : mytext = mytext[:-1] mytext += 'n' print mytext ms = IO.MemoryStream(Encoding.UTF8.GetBytes(mytext)) #Add tempfile back into Spotfire using TextFileDataSource readerSet = TextDataReaderSettings() readerSet.Separator = "," readerSet.AddColumnNameRow(0) textDataSource = TextFileDataSource(ms, readerSet ) try: Document.Data.Tables['HTMLTOTABLE'] except: myNewTable = Document.Data.Tables.Add("HTMLTOTABLE",textDataSource) #If you want to change the data table to be embedded and not linked, use the following code settings = DataTableSaveSettings (myNewTable,False, False); Document.Data.SaveSettings.DataTableSettings.Add(settings); table2 = Document.Data.Tables["HTMLTOTABLE"] table2.ReplaceData(textDataSource) Link to comment Share on other sites More sharing options...
Tyger Guzman 2 Posted January 23, 2020 Share Posted January 23, 2020 You can dynamically create document properties using https://community.tibco.com/wiki/how-add-new-document-property-tibco-spotfire-using-ironpython but I'm not sure you'll be able to use the script to insert those document properties into the Text Area (the script is to create a document propery but not sure if you can update the text area to display it. Link to comment Share on other sites More sharing options...
zinaw Tesemma Posted January 23, 2020 Author Share Posted January 23, 2020 Thanks a lot, this covered most of the challenges. After making adjustment to account for the <input> field, the HTMLTOTABLE capture all columns, except what the value user entered in the input field. on static input field it is doable since we are assigning them to Document Properties, but in this instance the html is created dynamically where there is no Document Properties. is there a way to capture the values or is there way to create Dynamic Document Properties via script when generating the html thanks Link to comment Share on other sites More sharing options...
zinaw Tesemma Posted January 23, 2020 Author Share Posted January 23, 2020 Thanks yes, you are correct, that is more for script side. Another way I am looking at this issue, if there is a way to capture data from an input field. where the input field is not assigned to Document Properties To test it out, I assigned a default value to be assigned when generating the input fields dynamically. After I made a change tto the default value via textarea, I run the script and it is only getting the original default value not the modified value. that is the difficult I am having, not sure anything I need to do to make the html or the input field recognize the new data/updates Link to comment Share on other sites More sharing options...
Tyger Guzman 2 Posted January 23, 2020 Share Posted January 23, 2020 Have you tried unchecking the "Execute in Transaction" box in the python script. or in your script to create the table try to add a space to the of the TextArea so that new data is read. for viz in page.Visuals: if viz.TypeId == VisualTypeIdentifiers.HtmlTextArea: viz.As[HtmlTextArea]().HtmlContent += " "; else: pass Link to comment Share on other sites More sharing options...
zinaw Tesemma Posted January 23, 2020 Author Share Posted January 23, 2020 Thanks for update, still no solution. I am not sure if this is html issue or HTMLContent issue I can capture and post the value anywhere in the page. but when capturing the vis.HtmlContent , they just disappear, they don't show up anywhere in any tag also, the input field will let my input value change the default value, but trying to read it where the script don't recognize value... Link to comment Share on other sites More sharing options...
zinaw Tesemma Posted January 24, 2020 Author Share Posted January 24, 2020 or is it possible to use JS to capture it table instead of IR script, just not familiar with JS Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now