RichFaces 4 ExtendedDataTable - Selecting rows programmatically - javascript

Good evening. I've been asked to update a web app that was implemented in RichFaces. The application has a rich:extendedDataTable inside of a composite component that displays some searchable data. The update I've been asked to implement is to have the first row in the table automatically selected when a search is submitted. I couldn't find a way to do this from the backing bean, but I did see that it can be done with the JavaScript API, by calling the selectRow and setActiveRow functions, but the problem is that I need the 'clientId' of the table, and if I inspect the DOM and get the client id of the table, let's say "junk:tableId", and I hard code that into the function,
#{rich:component('junk:tableId')}.selectRow(0);
#{rich:component('junk:tableId')}.setActiveRow(0});
Things work like I need them to. To retrieve the clientId, I found the rich:clientId function, and I confirmed that rich:clientId('tableId') returns the same clientId that I got from the DOM, so I updated my original function calls
#{rich:component('rich:clientId('tableId')')}.selectRow(0);
#{rich:component('rich:clientId('tableId')')}.setActiveRow(0});
And it doesn't work, and now I'm not sure what to try. Does anyone know what I can try?

You can just go with #{rich:component('tableId')}, the function calls clientId internally anyway.
#{rich:component('rich:clientId('tableId')')}
This should be getting you a parse error. Single quotes mark a string, not a method argument.

Related

Using JS Object Based Multidimensional Arrays to Collect, Store, and View Data in a PDF Form

I have an interactive PDF form created in Acrobat that employs a multidimensional object to collect, store, and populate form fields used to view the data. The form serves as a password manager to view individual password records whereby I have recently completed the lookup record page view that works like a charm. The only issue I've run into thus far is my inability to delete a record selected in the lookup view in which event I initially thought I'd be able to use the JS array.splice() method to simply delete a line item in the object array that stores the data for the particular record I want to delete. Come to learn that the script used to create the object that stores the data still remains inside the form whereby literally nothing has changed. Upon further study, I am inclined to believe that the form is essentially serving as a window to view the information stored in the object and for whatever reason invoking a script using the JS slice() method has no effect whatsoever on the script that created the object to begin with. Hence, in order to make this work, it appears I need to be able to rewrite/replace the script minus the object property/s that hold the data for the record to be deleted. Sorry for the novel. Any comments or suggestions regarding this subject matter are most appreciated. Thank you ahead of time.
Created a script using the JS splice() method in a futile attempt to remove data from an object used to collect and store data inside an interactive PDF form.
From Adobe's Docs:
You can use the Document JavaScript dialog box to add, edit, or delete scripts in your current document.
To open the dialog box, choose Tools > JavaScript > Document JavaScript.
Here https://helpx.adobe.com/uk/acrobat/using/add-debug-javascript.html
I've never used Adobe Acrobat, but if you need to edit a script in a PDF, that's probably where to get at it.
If you post the script's code, someone might be able to help you. It's almost impossible to get an answer to any question without posting code.
I apologize regarding my initial post as I knew little to nothing at the time regarding how to create and use an object literal in which event I have since learned how to use an object literal along with its methods to add, delete, and edit key-value pairs of an object literal. I was then able to resolve all my issues in using an Acrobat PDF form as a front end along with a hidden text field using JSON to convert a JS data object for organizing and storing my form data as a string. The script to accomplish this task is as follows:
dsFld =getField("dataSrc");// call getField method used to obtain the
stored JS object as a JSON string
oVendors = JSON.parse(dsFld.value);//Parse the JSON string to manipulate
the JS data object
btnDel=getField("btn.del");
var oFld;// create var oFld for later use
var oPassData = oVendors[event.value];
if(oPassData){// script to populate PDF form fields
//walk members to fill fields
for(var nNm in oPassData){
// skip fields that don't exist on form
oFld = this.getField("inf." + nNm);
if(oFld)
oFld.value = oPassData[nNm];// script to populate associated form
fields
}
In looking back, I am sorry for any inconvenience posed by my initial post.

How to remove the html generated from razor var to Javascript variable?

I'm using MVC5 and passing model from Controller to View. In the view I have
var test = #Html.Raw(Json.Encode(Model.Data));
It work great, I have my model in the js variable. The problem is when I'm going to see my HTML code, the whole variable is rendered
Is there any way how I can remove or hide this code?
Thanks
To pass a variable from your server to the client you have two options really:
Do what you have done (but the value is rendered in markup)
Expose a webapi and query the endpoint in javascript to get the data
Option 2 is best practice.
Without more details on what you're trying to achieve I can't give a more detailed answer, but basically you should be looking into webapi to resolve this.
note: there are other things you could do like websockets and cookies, but it's unlikely that you want that kind of stuff for this

node.js html querying and parsing

How do i make a dynamic search bar?
Do i need to use html methods? How can i make the bar dynamic?
Hi, i just started learning node.js... while i never developed web applications.
I don't want you to write the code, i just want you to point me to the right direction.
<form>
<input type="text" name="search" placeholder="Search..">
</form>
Now, how do i get the information someone types in the search bar? And what should i use to have the search bar display information without reloading the page?
Assuming you will not use any JS framework, the easiest way is to use a input with auto-complete feature. One example:
http://jqueryui.com/autocomplete/
A similar question:
jQuery autocomplete with callback ajax json
you could use socket.io to create a bidirectional connection with your server, and update your list each time something new pop's up
and if you're new to the server, take a look at my blog:
https://mathieuauclairweb.wordpress.com/2017/05/02/how-to-make-a-nodejs-server-with-to-database-part-1/
I might add a tutorial on how to use socket.io this afternoon
You have to use both JavaScript(jQuery) client-side code to make AJAX calls on 'keyup' handler and server-side PHP (or whatever language you use) routine to handle that AJAX call and answer it with JSON array.
If your search will return only plain text results, then you can check aria-autocomplete on the Internet. There are plenty examples. In this method your server answer should contain a JSON array. In a very similar way you can also populate <option> tags in a <select>.
If you dig much more without using aria-autocomplete you can make your own custom-styled display of answers. You can take a look at my site http://www.zahranvane.com/ (only in Bulgarian language, sorry). There is a search field in the header. Type some number (like 511) and you will see matching results in a poping div. To achieve this approach the server-side script returns formatted HTML which replaces the content of the poping div.
As #user3429660 advice you use jquery autocomplete.
Create a function who call a webservice that you have defined in your nodejs with express for example. the web service return data in JSON to the function and the view is updated with jquery
1) What you are looking for is getting the value out of the input:
Get the value in an input text box
2) Not reloading page -> look into AJAX (many tutorials online...)

Netsuite: How to edit or update a record?

I am a newbie at NetSuite scripting. It looks like a normal EDIT or UPDATE function is not at all normal in the Netsuite. There are APIs for creating and deleting record like nlapiCreateRecord and nlapiDeleteRecord, but nowhere in the documentation I could find the way to edit and update the existing record. I have restrictions on using PHP.
I have created a custom TFC customer form (server side js), which should be able to fetch the data and update if required. I have been able to fetch the records as of now, but please tell me how to update an existing record?
To be a little more precise, use nlapiLoadRecord to fetch the record from the database. Set the fields as needed. Use nlapiSubmitRecord to save it.
Untested code off the top of my head:
var record = nlapiLoadRecord('record_type_goes_here', internal_id_of_record_goes_here);
record.setFieldValue('field_internal_id_goes_here', 'value to set goes here);
nlapiSubmitRecord(record);
Fill in the appropriate values where needed.
For the benefit of anyone looking at this question who is concerned with performance, it is much more efficient to use
nlapiSubmitField(type, id, fields, values, doSourcing)
If you know exactly what you are updating. This is both faster than submitRecord, and avoids the often significant overhead of loading the record first.
The function used to edit an existing record is nlapiSubmitRecord. See definition here http://suitecoder.appspot.com/static/api.html

Updating field in CRM 2011 through javascript from ribbon button on homegrid view

I am trying to create a button on the initial list or homegrid view of leads that will set the value of a specific field to the same value every time for the lead that is selected. Anyone know how i can do this through javascript?
Thanks!
To build on James's answer, you can use the CrmParameter SelectedControlSelectedItemIds to get a list of all the leads selected in a homepage grid. There is an answer on the MSDN forums that explains how to do this, copied below. You can do this in the Xml source or in the two CRM ribbon editors I know of.
After that, you would then need to use the Update method of one of the CRM webservices to loop through the Guid array and update each entity/database row accordingly. I've mentioned Avanade's excellent web resource before, and MSDN has some additional documention on this as well.
Walkthrough: Use the SOAP Endpoint for Web Resources with JScript
Sample: Create, Retrieve, Update and Delete Using the REST Endpoint with JavaScript
<CommandDefinition Id="Account.Form.CustomGroup.Button.A.Command">
<Actions>
<JavaScriptFunction Library="$webresource:AccountFormLibrar"
FunctionName="CreateNewAccount">
<CrmParameter Value="SelectedControlSelectedItemIds"/>
</JavaScriptFunction>
</Actions>
</CommandDefinition>
function CreateNewAccount (prmRecordGUID) {
//prmRecordGUID will recieve all GUIDS in comma seperated i.e. GUID1,GUID2,GUID3
}
Yeah this should be pretty straightforward - I dont think what you have said in your comment will work - that function you are trying to use only works if the form of the record is open, e.g. it wont work from a grid view.
You will have to use a webservice call as described in the MSDN here: http://msdn.microsoft.com/en-us/library/hh771584#BKMK_DataAccessUsingJavaScript
Also if you are customising the ribbon (adding buttons) you would find it a lot easier with this tool: http://www.develop1.net/public/page/Ribbon-Workbench-for-Dynamics-CRM-2011.aspx

Categories

Resources