Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/449.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在DOJO(基于JavaScript的工具包)中,让网格行在单击时执行一些事件,比如打开任何文档,比如pdf_Javascript_Dojox.grid.datagrid_Dojox.grid_Dojo - Fatal编程技术网

在DOJO(基于JavaScript的工具包)中,让网格行在单击时执行一些事件,比如打开任何文档,比如pdf

在DOJO(基于JavaScript的工具包)中,让网格行在单击时执行一些事件,比如打开任何文档,比如pdf,javascript,dojox.grid.datagrid,dojox.grid,dojo,Javascript,Dojox.grid.datagrid,Dojox.grid,Dojo,我想对行执行点击事件,Json数据来自一个servlet,它是contaainig数据,roll number是唯一的字段,我想通过它打开一个pdf文档,该文档本身被命名为roll number。请帮我做这件事 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> <!DOCTYPE html>

我想对行执行点击事件,Json数据来自一个servlet,它是contaainig数据,roll number是唯一的字段,我想通过它打开一个pdf文档,该文档本身被命名为roll number。请帮我做这件事

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"
    %>
    <!DOCTYPE html>
    <html>
    <head>
    <script>

    function onReportTypesSelect()
    {
        if(getDijitValue('data_types') != 'Select')
            {

            if(getDijitValue('data_types') == 'class_level')
            {
                require([
                            "dojo/store/JsonRest",
                            "dojo/store/Memory",
                            "dojo/store/Cache",
                            "dojox/grid/DataGrid",
                            "dojo/data/ObjectStore",
                            "dojo/query",
                            "dojo/domReady!"

                        ], function(JsonRest, Memory, Cache, DataGrid, ObjectStore, query){
                            var userStore, dataStore, grid;
                            userStore = new Cache(JsonRest({target: "<%=request.getContextPath()%>" + "/data/classServlet"}), new Memory()); 
                            grid = new DataGrid({
                                id:"class_level_grid",
                                store: dataStore = new ObjectStore({objectStore: userStore}),
                                structure: [
                                            {name: 'Roll Number', field: 'roll', width: 'auto', defaultValue: ""},
                                             {name: 'Name', field: 'name', width: '100px', defaultValue: ""},
                                            {name: 'Class', field: 'class', width: '75px', defaultValue: ""}
                                ],
                            style:"font-family: calibri, Garamond, Comic Sans; font-size: 10;",
                            selectionMode:'single',  
                            autoHeight: 10,
                            rowsPerPage:40,
                            rowSelector:'20px',
                            selectable: true
                            }

                            , "class_level_grid_div"); // make sure you have a target HTML element with this id
                            grid.startup();

                        });

            }
    }
    }
    </script>
    </head>`enter code here`
    <body>
    <div id="data_types" data-dojo-type="dijit/form/Select" style="width: 200px;" onchange="onReportTypesSelect()">
                         <span data-dojo-value="Select"><b>Select</b></span>
                        <span data-dojo-value="class_level"><b>class Level</b></span>
    </div>
    <div id="class_level_grid_div" style="width: 95%; height: 90%;"> </div>
    </div>
    </body>
    </html>

最简单的方法是为行设置onClickhandler

当我们选择并存储在网格中时,我需要强调我们服务的单一功能。这是我的工作区,也许对你有帮助

 OnClickZoom = on(yourGridName,"RowDblClick", function(evt){
            //get the clicked rowindex
            var idx = evt.rowIndex, item = this.getItem(idx);
            //  get a value out of the item
            var value = this.store.getValue(item, "yourFieldName");
            //highlight geometry
            highlightGeometry(value, true);
          });
在您的情况下,您必须获得您的rollnumber或可用于打开所需PDF的字段。差不多

"..//myMenu/myPDF/"+theFileName+".pdf";

问候

谢谢你的帮助。你能在以下方面进一步帮助我吗:是否可以在Javascript/DOJO中打开任何pdf文件/文本文件进行编辑?如果可以,请告诉我如何操作。