【发布时间】:2017-01-18 02:10:29
【问题描述】:
我关注 JSFiddle,它基本上有 jqxGrid 和 交通方式 单列,jqxPanel 在它的左侧,其中包含一些包含在模式中的单词的文本内容运输专栏。
现状:
当用户单击列的单元格值时,单击的单词会在段落中突出显示。这种方法的问题在于,它突出显示了列中我不想要的所有单词。文本内容中可能存在我只想突出显示特定单词而不是段落中出现的所有单词的情况。
我有可用的 jSON 数据,其中包含 Modes of Transportation 列中每个单词的 start 和 stop 字符偏移值,例如,如下所示:
{
"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": "Bus",
"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": "Train",
"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": "Airways",
"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
}]
}
其中,doc_content 是我在 JS Fiddle 中的文本内容(在 JSON 中不同,只是为了测试目的)。
我的目标:
如何将Modes of Transportation 列中的start 和stop 值与文本内容中的特定单词相关联?有没有办法,Rangy 库可以在这里出现?我看到了Rangy Range 文档,但看起来他们正在根据用户选择生成开始和结束字符偏移量。如果我已经有 start 和 stop 字符偏移值,如 JSON 中所示,我找不到任何具体的操作。请指教。谢谢
【问题讨论】:
标签: javascript jquery json rangy