cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Editing and saving grid data

GAjey
9-Granite

Editing and saving grid data

I want to save the data I bound to the grid while some (not all)  rows users can edit.

I need to save both edited and unedited rows. currently, I'm getting only those rows that are edited. I need all the grid data. My Thingworx version is 9.3.3-b20.

if anyone know how to achieve it please help.

 

 

 

7 REPLIES 7
PaiChung
22-Sapphire I
(To:GAjey)

Since you are populating the grid, that means you know the 'original state' then you combine that with the 'edited rows'

You should be able to use the infotable functions or if the data is in a datatable, you can use datatable functions for that server side.

After that you can return the new full grid set.

GAjey
9-Granite
(To:PaiChung)

I thought the same solution for it but iterating over info table data , recognizing edited rows then replacing those seems not efficient. can you please help if you know any info table function that can do it efficiently or with fewer lines of code? I tried the OOTB snippet "Union" but it doesn't work.

PaiChung
22-Sapphire I
(To:GAjey)

You'll have to doublecheck, but I think a DataTable supports 'Update Query' I don't remember if that is possible for an infotable as well (or the other way around).

 

GAjey
9-Granite
(To:PaiChung)

I tried the UpdateQuery snippet under infotable functions, but using that snippet gives me only those rows which I have edited.

I need all unedited rows and edited rows with updated values. 

PaiChung
22-Sapphire I
(To:GAjey)

What does your actual code look like?

GAjey
9-Granite
(To:PaiChung)

Please find below code

   
   //make query**************
    let queryArray=[];
   
    editedData.rows.toArray().forEach(row => {
    //Your code here
       let filterItem= {

                "fieldName": "id",

               "type": "LIKE",

               "value": row.id
          };
        queryArray.push(filterItem);
});
 let query={

    "filters": {

        "type": "OR",
        "filters":queryArray
    	}
    };
   
   logger.error(JSON.stringify(query));
    //@@@@@@@@@@@@@@@@@@@@@@@@
    
    let params2 = {
	t:editedData INFOTABLE,
	query: query QUERY,
	values: inputData INFOTABLE
};

// result: INFOTABLE
 result = Resources["InfoTableFunctions"].UpdateQuery(params2);
PaiChung
22-Sapphire I
(To:GAjey)

What if you set editedData to result after executing the update query?

like:

   Resources["InfoTableFunctions"].UpdateQuery(params2);

   result = editedData

Top Tags