When a user clicks on a particular row (I am using jqgrids), I am displaying a document content inside a jqxpanel just below the jqxgrid. A second jqxgrid is displayed simultaneously on the side of the jqxpanel with only a single column containing multiple rows. Each row contains a single word that exists somewhere in the document content. So, what I am trying to achieve is when a user clicks on that particular word, it should get highlighted in yellow color into the document content.
I am pulling up information for document and words from a JSON data using an jQuery Ajax call. the JSON data is mentioned below.
{
"webservice_status": {
"status": "SUCCESS",
"message": ""
},
"documentContent": [{
"webservice_status": null,
"id": "4321",
"wordTo_highlight": "Car",
"document_id": 678767,
"date_value": "2016-04-27",
"doc_content": " Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n\n Sedan Final Report- 4/28/2016 14:38 CDT -\n\n CASE: Z-77-7654\n\n Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n",
"stop": 645,
"start": 638
}, {
"webservice_status": null,
"id": "4321",
"wordTo_highlight": "SUV",
"document_id": 678767,
"date_value": "2016-04-27",
"doc_content": " Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n\n Sedan Final Report- 4/28/2016 14:38 CDT -\n\n CASE: Z-77-7654\n\n Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n",
"stop": 2890,
"start": 2883
}, {
"webservice_status": null,
"id": "4321",
"wordTo_highlight": "Car",
"document_id": 678767,
"date_value": "2016-04-27",
"doc_content": " Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n\n Sedan Final Report- 4/28/2016 14:38 CDT -\n\n CASE: Z-77-7654\n\n Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n",
"stop": 1156,
"start": 1149
}, {
"webservice_status": null,
"id": "4321",
"wordTo_highlight": "SUV",
"document_id": 678767,
"date_value": "2016-04-27",
"doc_content": " Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n\n Sedan Final Report- 4/28/2016 14:38 CDT -\n\n CASE: Z-77-7654\n\n Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n",
"stop": 2970,
"start": 2963
}, {
"webservice_status": null,
"id": "4321",
"wordTo_highlight": "SUV",
"document_id": 678767,
"date_value": "2016-04-27",
"doc_content": " Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n\n Sedan Final Report- 4/28/2016 14:38 CDT -\n\n CASE: Z-77-7654\n\n Company Name:Car Transportation\n\n id: 000004321\n\n Vehicle Report\n\n\nExcellent Condition: Z-77-7654 Received Date/Time: 4/27/2016 13:02 CDT\n Collected Date/Time: 4/27/2016 13:02 CDT\n\n",
"stop": 3744,
"start": 3737
}]
}
As can be seen, the words that needs to be highlighted are written next to the key wordTo_highlight
and it’s value is mentioned next to it. In our case, Car
and SUV
are the words that needs to be higlhighted in the document. The document content is next to the key doc_content
.
All the JSON keys and values (except for stop and start) are identical and repeated 4 times because there are 4 words that needs to be highlighted.
The start and stop integer values corresponds to the location of the word that needs to be highlighted in yellow color.I am wondering how should I approach this problem to move forward?