小编Fre*_*d A的帖子

关于JqGrid流程事件

只是想更好地了解JqGrid事件过程

  • beforeRequest
  • loadBeforeSend
  • serializeGridData
  • loadError
  • gridComplete
  • loadComplete

基于此事件

  • 如果我想在ajax请求中向服务器添加过滤器或额外参数,我应该在loadBeforeSend中执行吗?
  • 从服务器获取数据后,如果我想阻止数据显示在网格中(我想先进一步处理它,之后只显示处理过的数据),我应该在gridComplete中做到这一点吗?

因为我的工作要求我在向服务器发送请求时添加额外的参数,并且在收到数据之后,我需要阻止网格在网格上显示数据,以便我可以在显示处理数据之前进一步处理数据网格.但我似乎无法掌握JqGrid应该将我的功能放到哪个事件.

谢谢


编辑:

对于postData部分

loadBeforeSend: function() {
    if (sessionStorage.pathStates == "edit" && location.pathname.indexOf("list") > -1) {
        console.log("SUCCESS");
        loadFilter();
    }
},
Run Code Online (Sandbox Code Playgroud)

和loadFilter

function loadFilter() {
    var filter = JSON.parse(sessionStorage.filter);
    var filterInput = [],
        model = [],
        filters = {};
    filterInput = filter.filterInput;
    model = filter.model;
    var grid = filter.grid,
        page = filter.page,
        op = "bw",
        a = 0,
        b = 0; …
Run Code Online (Sandbox Code Playgroud)

jquery jqgrid

7
推荐指数
1
解决办法
2909
查看次数

使用 NextJS API 发送文件作为响应

如题,

在 NodeJs + Express 中,我可以使用以下行返回一个文件作为响应

res.sendFile(absolute_path_to_the_file)
Run Code Online (Sandbox Code Playgroud)

假设我想从 NextJs 目录中的输出文件夹返回单个图像,我如何使用 NextJs API 实现这一点?我只能看到 res.send() 和 res.json() 作为返回响应的方式,我不确定如何利用它将图像作为响应返回给调用者。

如果我喜欢这个

res.send(absolute_path_to_the_file)
Run Code Online (Sandbox Code Playgroud)

它只会向我发送目录路径的字符串。我期望的是从目录路径表示的目录发送的图像。

在这里需要帮助。

node.js express next.js

7
推荐指数
2
解决办法
3423
查看次数

有人可以从事件循环的角度向我解释一下吗?

我这里有以下 React 片段

****** Example.js *******

    import React from 'react';

    export default const SampleApp =  props => {
        const [text, setText] = React.useState('Some name in here');

        console.log(`[1] The value of the text is - ${text}`); // ---(1)

        React.useEffect(() => {
            setText('Ohhh yeah ma boy');
            console.log(`[2] The value of the text is - ${text}`); // --- (2)
        }, []);

        React.useEffect(() => {
            console.log(`[3] The value of the text is - ${text}`); // --- (3)
            setText('Yare yare daze');
        }, [text]);

        console.log(`[4] The …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

5
推荐指数
1
解决办法
869
查看次数

使 MUI 对话框内容大小跟随内容的大小

正如标题所示,

我想在页面加载时在对话框中显示 Youtube 视频,其中它会自动打开对话框并播放 Youtube 视频。所以我在这里为我的登陆页面准备了这个组件

// Main Application container
import React, { useState } from 'react';
import { BrowserRouter } from 'react-router-dom';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { withStyles } from '@material-ui/core/styles';
// Application routes
import AppRoutes from '../routes';
// YouTube component
import YouTube from 'react-youtube';
// Components
import HeadNav from '../components/header/Nav';
import Footer from '../components/footer/Footer';
import Grid from '@material-ui/core/Grid';
import Dialog from '@material-ui/core/Dialog';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';

const styles = …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

4
推荐指数
1
解决办法
1万
查看次数

在Angular中显示包含HTML标记的字符串

我在SO中检查了答案,但找不到令人满意的答案.所以我在这里问:

我有一个字符串如下

var string = "With this you have agreed with the <a href='#'>rules and condition</a>"
Run Code Online (Sandbox Code Playgroud)

我需要将其呈现为字符串(对于文本部分)和HTML(对于HTML部分).

我如何在AngularJs中实现这一目标?我试过$compile但它对我不起作用,它在页面上输出看似缩小代码的块.

html href angularjs angularjs-ng-href

2
推荐指数
1
解决办法
7208
查看次数

对 React-Data-Grid 中的某些列进行验证

我想在react-data-grid表上实现验证,其中只有我在列本身中定义的单元格才会被验证,并且只有在状态设置为true时才会发生验证。

所以我这里有以下代码

const [ validateMode, setValidateMode ] = useState(false);
const errorBackground = { backgroundColor: 'some error color in here' }


const DescriptionFormatter = props => {
    const { value, row } = props;
    let template;

    if (!validateMode){
        template = value;
    }

    if (validateMode){
        let validationStyling = Boolean(value.length) ? {} : errorBackground;
        template = <div style={{ ...validationStyling }}>value</div>
    }

    return template;
}

const tableCols = [
    {
        key: 'id',
        name: 'No'
    },
    {
        key: 'name',
        name: 'Name',
        editable: !disabled,
        editor: <AutoComplete …
Run Code Online (Sandbox Code Playgroud)

reactjs react-data-grid

2
推荐指数
1
解决办法
3318
查看次数

编写SQL查询时几乎没有疑问

我在这里几乎没有问题

  • 我总是看到一些SQL编写如下(不确定我是否正确)

    SELECT a.column_1, a.column_2 FROM table_name WHERE b.column_a = 'some value'
    
    Run Code Online (Sandbox Code Playgroud)

    我不太了解以这种方式编写的SQL.它是否类似于在编程中使用对象,您可以在对象中定义对象和变量?如果是,上面的SQL的a和b的定义在哪里(假设我的查询正确)?

  • 我想在3个不同的表中比较3列(比如C1 C2 C3),比如T1 T2和T3.条件是从T1中的C1获得值,在T2中存在于C2中,但在T3中不存在于C3中.这两列实际上是相同的,只是有些列可能与其他2个表中的其他列不同或更少的记录,我想知道差异是什么.查询是否以正确的方式执行此操作?

    select distinct C1 from T1
    and (C1) not in (select C2 from T2)
    and (C1) in (select C3 from T3)
    order by C1; 
    
    Run Code Online (Sandbox Code Playgroud)

    如果我想使用上面的查询包含更多的表进行比较,是否可以扩展条件?

  • 如果我要将上面的查询自定义为类似于第一个问题的东西,那么查询是否以正确的方式进行?

    select a.C1 from T1 a
    and (a.C1) not in (select b.C2 from T2 b)
    and (a.C1) in (select c.C3 from T3 c)        
    order by a.C1;
    
    Run Code Online (Sandbox Code Playgroud)
  • 与以传统方式编写查询相比,以对象方式编写查询(如上所述)的优势是什么?我觉得即使您将表名定义为变量,该变量也只能在定义它的查询中使用,并且不能扩展到其他查询.

谢谢

sql

1
推荐指数
1
解决办法
428
查看次数

NextJs 项目版本从 9.0.1 升级到 9.0.4 的问题

我将我的项目版本从 package.json 从 9.0.1 升级到 9.0.4

"next": "9.0.4"
Run Code Online (Sandbox Code Playgroud)

此项目升级的目的是使用 NextJs 9.0.4 版中包含的内置压缩。

而且我已经确保,根据 NextJs 文档,来自 next/document 的 Head 仅在 _document 内部使用,而来自 next/head 的 Head 用于其他任何地方。

import Document, { Html, Head, Main, NextScript } from "next/document"; // For _document.js use only
import Head from "next/head"; // For every other pages and _app
Run Code Online (Sandbox Code Playgroud)

在这个项目版本升级后,我注意到了几件事

首先,缺少下一个人数统计标签。当我在开发模式下运行它时,它弹出了这个控制台错误

index.js:1 Warning: next-head-count is missing. https://err.sh/next.js/next-head-count-missing
Run Code Online (Sandbox Code Playgroud)

我检查了这个,发现 next-head-count 是在 body 标签内渲染的,而它应该在 head 标签内渲染。

其次,我注意到链接标签和标题都在 head 和 body 标签内呈现。

<head>
  // All the link tags rendered in here …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js

0
推荐指数
1
解决办法
858
查看次数